Hello friends,
Cakephp provides a utility packages of logic that are shared between controllers.You can also create your own components. If you find yourself wanting to copy and paste things between controllers, you should consider creating your own component to contain the functionality.
Creating the Components.
Components extend the Object Class. This is use CamelCase naming convention. All components are suffixed with ‘Component’.
class DomainSearchComponent extends Object {
function checkDomain() {
}
}
How to use components.
Cakephp gives a variable $components that is use into the class.
class DomainnamesController extends AppController {
var $components = array('DomainSearch');
function search() {
return $this->DomainSearch->checkDomain();
}
}
0 Comment(s)