本文整理汇总了PHP中Cake\Controller\Controller::components方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::components方法的具体用法?PHP Controller::components怎么用?PHP Controller::components使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Controller\Controller
的用法示例。
在下文中一共展示了Controller::components方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getController
/**
* Returns the test controller
*
* @param \Cake\Network\Request $request Request object
* @param \Cake\Network\Response $response Response for the controller.
* @return \Cake\Controller\Controller
*/
protected function _getController($request, $response)
{
if ($this->testController === null) {
$this->testController = parent::_getController($request, $response);
}
$default = array('InterceptContent' => array('className' => 'Cake\\TestSuite\\InterceptContentHelper'));
$this->testController->helpers = array_merge($default, $this->testController->helpers);
$this->testController->setRequest($request);
$this->testController->response = $this->response;
$registry = $this->testController->components();
foreach ($registry->loaded() as $component) {
$object = $registry->{$component};
if (isset($object->response)) {
$object->response = $response;
}
if (isset($object->request)) {
$object->request = $request;
}
}
return $this->testController;
}
示例2: _initControllerAndRatings
/**
* Convenience method for testing: Initializes the controller and the Ratings component
*
* @param array $params Controller params
* @return void
*/
protected function _initControllerAndRatings($params = [])
{
$_default = ['?' => [], 'pass' => []];
$this->Controller->request->params = array_merge($_default, $params);
if (!empty($this->Controller->request->params['?'])) {
$this->Controller->request->query = $this->Controller->request->params['?'];
}
$this->Controller->components()->unload('Ratings');
$options = isset($this->Controller->components['Ratings.Ratings']) ? $this->Controller->components['Ratings.Ratings'] : [];
$this->Controller->loadComponent('Ratings.Ratings', $options);
$event = new Event('beforeFilter', $this->Controller);
$this->Controller->Ratings->beforeFilter($event);
//$this->Controller->Components->trigger('initialize', array(&$this->Controller));
//$this->Controller->Auth = $this->AuthComponent;
//$this->Controller->Ratings->beforeFilter($this->Controller);
}
示例3: testManipulationHandling
public function testManipulationHandling()
{
$request = new Request(['url' => 'controller_posts/index?Filter-Posts-title=foo&Filter-Posts-body=bar&Filter-Posts-author_id=invalid&Filter-Posts-multi[0]=valid1&Filter-Posts-multi[1]=invalid', 'action' => 'index', '_method' => 'POST']);
$request->action = 'index';
$controller = new Controller($request);
$controller->listFilters = ['index' => ['fields' => ['Posts.title' => ['searchType' => 'wildcard'], 'Posts.author_id' => ['searchType' => 'select', 'options' => ['valid' => 'valid']], 'Posts.multi' => ['searchType' => 'multipleselect', 'options' => ['valid1' => 'valid1', 'valid2' => 'valid2']]]]];
$controller->paginate = [];
$ListFilter = new ListFilterComponent($controller->components(), []);
$event = new Event('Controller.startup', $controller);
$ListFilter->startup($event);
// the 'body' field from the filter URL is not configured in listFilters and
// should not be added to the paginate array
// author_id has a value not defined in the options key of the listFilter config
// and must be ignored
$this->assertEquals(['conditions' => ['Posts.title LIKE' => '%foo%', 'Posts.multi IN' => ['valid1']]], $controller->paginate);
}