当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::components方法代码示例

本文整理汇总了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;
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:28,代码来源:ControllerTestCase.php

示例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);
 }
开发者ID:sonuchauhan,项目名称:cakephp-ratings,代码行数:22,代码来源:RatingsComponentTest.php

示例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);
 }
开发者ID:codekanzlei,项目名称:cake-list-filter,代码行数:16,代码来源:ListFilterComponentTest.php


注:本文中的Cake\Controller\Controller::components方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。