LoginSignup
0
0

More than 5 years have passed since last update.

【サルが書く】cakephp2のcomponent内でcomponentを使うぞ

Last updated at Posted at 2018-02-02

公式cookbookから引用



// app/Controller/Component/CustomComponent.php
// コンポーネントを使う方

App::uses('Component', 'Controller');
class CustomComponent extends Component {
    // 実装中のコンポーネントが使っている他のコンポーネントここで指定する
    public $components = array(
      'Existing'
    );

    public function initialize(Controller $controller) {
        $this->Existing->foo();
    }

    public function bar() {
        // ...
   }
}


// app/Controller/Component/ExistingComponent.php
// 使われるコンポーネント

App::uses('Component', 'Controller');
class ExistingComponent extends Component {

    public function foo() {
        // ...
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0