in app_controller.php load Session, Auth components.
And in posts_controller.php, i use CustomComponent with $components = array('Session','Auth');
Then do CustomComponent must reload Session, Auth components?
if i use and create much components and that components use other components .It will make app is very slow?
I asked in cakephp IRC, A person answer is not:
[11:05] it will not be slow, I believe it passes those around via reference
[11:05] so you have nothing to worry about
Lets say you want to import BComponent into AComponent.
AComponent
class AComponent extends Component {
public $components = array('BComponent');
public function xyz(){
$test = $this->BComponent->abc($name);
echo $test;
}
}
BComponent
class BComponent extends Component {
public function abc($name){
return "My name is: ". $name;
}
}
yes, it would need to be $components = array('Session','Auth','Custom'); Or you can use: App::import('Component', 'Custom');$Custom = new CustomComponent();
Then do CustomComponent must reload Session, Auth components? If you don't use Session or Auth inside your CustomComponent class, then no.
It will make app is very slow? No, unless you use a lot of components.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With