公式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() {
// ...
}
}