本文整理汇总了PHP中ComponentCollection::normalizeObjectArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ComponentCollection::normalizeObjectArray方法的具体用法?PHP ComponentCollection::normalizeObjectArray怎么用?PHP ComponentCollection::normalizeObjectArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComponentCollection
的用法示例。
在下文中一共展示了ComponentCollection::normalizeObjectArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components
* @param array $settings Array of configuration settings.
*/
public function __construct(ComponentCollection $collection, $settings = array()) {
$this->_Collection = $collection;
$this->settings = $settings;
$this->_set($settings);
if (!empty($this->components)) {
$this->_componentMap = ComponentCollection::normalizeObjectArray($this->components);
}
}
示例2: init
/**
* Initializes all the Components for a controller.
* Attaches a reference of each component to the Controller.
*
* @param Controller $Controller Controller to initialize components for.
* @return void
*/
public function init(Controller $Controller) {
if (empty($Controller->components)) {
return;
}
$this->_Controller = $Controller;
$components = ComponentCollection::normalizeObjectArray($Controller->components);
foreach ($components as $name => $properties) {
$Controller->{$name} = $this->load($properties['class'], $properties['settings']);
}
}
示例3: loadComponent
/**
* Loads a Component
*
* @param string $componentClass Name of model class to load
* @param array $settings array of settings
* @return void
* @access public
**/
public function loadComponent($componentClass, $settings = array())
{
if (empty($this->_internals['controller'])) {
$this->loadController();
}
$components = ComponentCollection::normalizeObjectArray(array($componentClass => $settings));
foreach ($components as $name => $properties) {
$this->_internals['controller']->{$name} = $this->_internals['controller']->Components->load($properties['class'], $properties['settings']);
$this->{$name} = $this->_internals['controller']->{$name};
}
if (method_exists($this->_internals['controller']->{$name}, 'initialize')) {
$this->_internals['controller']->{$name}->initialize($this->_internals['controller']);
}
if (method_exists($this->_internals['controller']->{$name}, 'startup')) {
$this->_internals['controller']->{$name}->startup($this->_internals['controller']);
}
}