/** * Constructor */ public function __construct() { parent::__construct(); $this->Permission = ClassRegistry::init(array('class' => 'Permission', 'alias' => 'Permission')); $this->Aro = $this->Permission->Aro; $this->Aco = $this->Permission->Aco; }
/** * Constructor * * @param array $options Optional load object properties. */ public function __construct($options = array()) { parent::__construct(); if (empty($options['name'])) { $this->name = preg_replace('/schema$/i', '', get_class($this)); } if (!empty($options['plugin'])) { $this->plugin = $options['plugin']; } if (strtolower($this->name) === 'cake') { $this->name = 'App'; } if (empty($options['path'])) { $this->path = APP . 'Config' . DS . 'Schema'; } $options = array_merge(get_object_vars($this), $options); $this->build($options); }
/** * Constructor. * * @param array $config Array of configuration information for the datasource. */ public function __construct($config = array()) { parent::__construct(); $this->setConfig($config); }
/** * Constructor. * * @param CakeRequest $request Request object for this controller. Can be null for testing, * but expect that features that use the request parameters will not work. * @param CakeResponse $response Response object for this controller. */ public function __construct($request = null, $response = null) { if ($this->name === null) { $this->name = substr(get_class($this), 0, -10); } if (!$this->viewPath) { $this->viewPath = $this->name; } $this->modelClass = Inflector::singularize($this->name); $this->modelKey = Inflector::underscore($this->modelClass); $this->Components = new ComponentCollection(); $childMethods = get_class_methods($this); $parentMethods = get_class_methods('Controller'); $this->methods = array_diff($childMethods, $parentMethods); if ($request instanceof CakeRequest) { $this->setRequest($request); } if ($response instanceof CakeResponse) { $this->response = $response; } parent::__construct(); }
/** * Constructor. Binds the model's database table to the object. * * If `$id` is an array it can be used to pass several options into the model. * * - `id`: The id to start the model on. * - `table`: The table to use for this model. * - `ds`: The connection name this model is connected to. * - `name`: The name of the model eg. Post. * - `alias`: The alias of the model, this is used for registering the instance in the `ClassRegistry`. * eg. `ParentThread` * * ### Overriding Model's __construct method. * * When overriding Model::__construct() be careful to include and pass in all 3 of the * arguments to `parent::__construct($id, $table, $ds);` * * ### Dynamically creating models * * You can dynamically create model instances using the $id array syntax. * * ``` * $Post = new Model(array('table' => 'posts', 'name' => 'Post', 'ds' => 'connection2')); * ``` * * Would create a model attached to the posts table on connection2. Dynamic model creation is useful * when you want a model object that contains no associations or attached behaviors. * * @param bool|int|string|array $id Set this ID for this model on startup, * can also be an array of options, see above. * @param string $table Name of database table to use. * @param string $ds DataSource connection name. */ public function __construct($id = false, $table = null, $ds = null) { parent::__construct(); if (is_array($id)) { extract(array_merge(array('id' => $this->id, 'table' => $this->useTable, 'ds' => $this->useDbConfig, 'name' => $this->name, 'alias' => $this->alias, 'plugin' => $this->plugin), $id)); } if ($this->plugin === null) { $this->plugin = isset($plugin) ? $plugin : $this->plugin; } if ($this->name === null) { $this->name = isset($name) ? $name : get_class($this); } if ($this->alias === null) { $this->alias = isset($alias) ? $alias : $this->name; } if ($this->primaryKey === null) { $this->primaryKey = 'id'; } ClassRegistry::addObject($this->alias, $this); $this->id = $id; unset($id); if ($table === false) { $this->useTable = false; } elseif ($table) { $this->useTable = $table; } if ($ds !== null) { $this->useDbConfig = $ds; } if (is_subclass_of($this, 'AppModel')) { $merge = array('actsAs', 'findMethods'); $parentClass = get_parent_class($this); if ($parentClass !== 'AppModel') { $this->_mergeVars($merge, $parentClass); } $this->_mergeVars($merge, 'AppModel'); } $this->_mergeVars(array('findMethods'), 'Model'); $this->Behaviors = new BehaviorCollection(); if ($this->useTable !== false) { if ($this->useTable === null) { $this->useTable = Inflector::tableize($this->name); } if (!$this->displayField) { unset($this->displayField); } $this->table = $this->useTable; $this->tableToModel[$this->table] = $this->alias; } elseif ($this->table === false) { $this->table = Inflector::tableize($this->name); } if ($this->tablePrefix === null) { unset($this->tablePrefix); } $this->_createLinks(); $this->Behaviors->init($this->alias, $this->actsAs); }
/** * Constructor * * @param Controller $controller A controller object to pull View::_passedVars from. */ public function __construct(Controller $controller = null) { if (is_object($controller)) { $count = count($this->_passedVars); for ($j = 0; $j < $count; $j++) { $var = $this->_passedVars[$j]; $this->{$var} = $controller->{$var}; } $this->_eventManager = $controller->getEventManager(); } if (empty($this->request) && !($this->request = Router::getRequest(true))) { $this->request = new CakeRequest(null, false); $this->request->base = ''; $this->request->here = $this->request->webroot = '/'; } if (is_object($controller) && isset($controller->response)) { $this->response = $controller->response; } else { $this->response = new CakeResponse(); } $this->Helpers = new HelperCollection($this); $this->Blocks = new ViewBlock(); $this->loadHelpers(); parent::__construct(); }