本文整理匯總了PHP中ComponentCollection::trigger方法的典型用法代碼示例。如果您正苦於以下問題:PHP ComponentCollection::trigger方法的具體用法?PHP ComponentCollection::trigger怎麽用?PHP ComponentCollection::trigger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ComponentCollection
的用法示例。
在下文中一共展示了ComponentCollection::trigger方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: render
/**
* Instantiates the correct view class, hands it its data, and uses it to render the view output.
*
* @param string $view View to use for rendering
* @param string $layout Layout to use
* @return CakeResponse A response object containing the rendered view.
* @link http://book.cakephp.org/2.0/en/controllers.html#Controller::render
*/
public function render($view = null, $layout = null)
{
$this->beforeRender();
$this->Components->trigger('beforeRender', array(&$this));
$viewClass = $this->viewClass;
if ($this->viewClass != 'View') {
list($plugin, $viewClass) = pluginSplit($viewClass, true);
$viewClass = $viewClass . 'View';
App::uses($viewClass, $plugin . 'View');
}
$View = new $viewClass($this);
if (!empty($this->uses)) {
foreach ($this->uses as $model) {
list($plugin, $className) = pluginSplit($model);
$this->request->params['models'][$className] = compact('plugin', 'className');
}
}
if (!empty($this->modelClass) && ($this->uses === false || $this->uses === array())) {
$this->request->params['models'][$this->modelClass] = array('plugin' => $this->plugin, 'className' => $this->modelClass);
}
$models = ClassRegistry::keys();
foreach ($models as $currentModel) {
$currentObject = ClassRegistry::getObject($currentModel);
if (is_a($currentObject, 'Model')) {
$className = get_class($currentObject);
list($plugin) = pluginSplit(App::location($className));
$this->request->params['models'][$currentObject->alias] = compact('plugin', 'className');
$View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors;
}
}
$this->autoRender = false;
$this->View = $View;
$this->response->body($View->render($view, $layout));
return $this->response;
}