PHP code example of eom / plugin-cakephp-loadsubcomponents

1. Go to this page and download the library: Download eom/plugin-cakephp-loadsubcomponents library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eom / plugin-cakephp-loadsubcomponents example snippets


    // Load Plugins ...
    CakePlugin::load('EOM/LoadSubComponents', array('bootstrap' => false, 'routes' => false));

    /**
     * Application Controller
     * @property LoadSubComponentsComponent $LoadSubComponents
     */
    class AppController extends Controller {
    
        public $components = ['EOM/LoadSubComponents.LoadSubComponents'];
    }

    /**
     * MiDemo Controller
     * @property MiFunctionDemo1Component $MiFunctionDemo1
     * @property MiFunctionDemo2Component $MiFunctionDemo2
     * @property MiFunctionDemo3Component $MiFunctionDemo3
     */
    class MiDemoController extends AppController {
    
        public function beforeFilter()
        {
                parent::beforeFilter();

                // Load path Controller/Component/SubDirectorios/TestDemoComponent.php
                $this->TestDemo = $this->LoadSubComponents->Load('SubDirectorios/TestDemo');

                // Load path Controller/Component/SubDirectorioX/MiFunctionDemo1Component.php
                $this->MiFunctionDemo1 = $this->LoadSubComponents->load('SubDirectorioX/MiFunctionDemo1');
                $this->MiFunctionDemo3 = $this->LoadSubComponents->load('SubDirectorio/SubX/MiFunctionDemo3');
    
                // Demo1 de como utilizarla
                $this->MiFunctionDemo1->MiAccion1('Demo');
                $this->MiFunctionDemo1->MiAccion2('Demo');
        }

        public function index(){

            // TestDemo de como utilizarla
            echo $this->TestDemo->hello('Hi EOM !!!');

            // Load path Controller/Component/SubDirectorioX/MiFunctionDemo2Component.php
            $this->MiFunctionDemo2 = $this->LoadSubComponents->load('SubDirectorioX/MiFunctionDemo2');
            
            // Demo2 de como utilizarla
            $this->MiFunctionDemo2->MiAccion1('DemoIndexBla');

            // Reutilizar Demo1 load en el __construct
            $this->MiFunctionDemo1->MiAccion101('DemoIndexBlaBla..');

            // Utilizar Demo3 load en el __construct
            $this->MiFunctionDemo3->MiAccionDemoBla('DemoIndexBlaBla..');
        }

        // ...

    }