本文整理汇总了PHP中Cake\Controller\Controller类的典型用法代码示例。如果您正苦于以下问题:PHP Controller类的具体用法?PHP Controller怎么用?PHP Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @return void
*/
public function setUp()
{
parent::setUp();
Configure::write('App.namespace', 'TestApp');
$this->Controller = new CacheComponentTestController();
$this->Controller->startupProcess();
$this->Controller->request->session()->delete('CacheMessage');
$this->Controller->Cache->config('debug', true);
}
示例2: testInnerComponentsAreNotEnabled
/**
* test that component components are not enabled in the collection.
*
* @return void
*/
public function testInnerComponentsAreNotEnabled()
{
$mock = $this->getMock('Cake\\Event\\EventManager');
$controller = new Controller();
$controller->eventManager($mock);
$mock->expects($this->once())->method('on')->with($this->isInstanceOf('TestApp\\Controller\\Component\\AppleComponent'));
$Collection = new ComponentRegistry($controller);
$Apple = $Collection->load('Apple');
$this->assertInstanceOf('TestApp\\Controller\\Component\\OrangeComponent', $Apple->Orange, 'class is wrong');
}
示例3: _getView
protected function _getView($viewVars = [])
{
$Request = new Request();
$Response = new Response();
$Controller = new Controller($Request, $Response);
$builder = $Controller->viewBuilder();
$builder->className('JsonApi\\View\\JsonApiView');
if ($viewVars) {
$Controller->set($viewVars);
}
return $Controller->createView();
}
示例4: __construct
/**
* Constructor.
*
* @param \Cake\Controller\Controller $Controller Controller instance.
*/
public function __construct(Controller $Controller = null)
{
if ($Controller) {
$this->_Controller = $Controller;
$this->eventManager($Controller->eventManager());
}
}
示例5: testPaginate
/**
* @return void
*/
public function testPaginate()
{
Configure::write('Paginator.limit', 2);
$ToolsUser = TableRegistry::get('ToolsUsers');
$count = $ToolsUser->find('count');
$this->assertTrue($count > 3);
$this->Controller->loadModel('ToolsUsers');
$result = $this->Controller->paginate('ToolsUsers');
$this->assertSame(2, count($result->toArray()));
}
示例6: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
// $this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', ['authorize' => ['Controller'], 'loginRedirect' => ['controller' => 'IndocreatorAdmin', 'action' => 'index'], 'logoutRedirect' => ['controller' => 'IndocreatorAdmin', 'action' => 'display', 'home']]);
}
示例7: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', ['authorize' => ['Controller'], 'authenticate' => ['Form' => ['fields' => ['username' => 'username', 'password' => 'password']]], 'loginRedirect' => ['controller' => 'Projects', 'action' => 'index'], 'logoutRedirect' => ['controller' => 'Projects', 'action' => 'index']]);
}
示例8: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->helpers[] = 'Shrink.Shrink';
$this->loadComponent('Auth', ['authorize' => 'Controller', 'authenticate' => ['Form' => ['fields' => ['username' => 'email', 'password' => 'password']]], 'loginAction' => ['controller' => 'CustomStaticPages', 'action' => 'index'], 'logoutAction' => ['controller' => 'CustomStaticPages', 'action' => 'index']]);
//$this->Auth->allow();
}
示例9: __construct
/**
* Constructor.
*
* @param \Cake\Controller\Controller $Controller
*/
public function __construct(Controller $Controller = null)
{
if ($Controller) {
$this->_Controller = $Controller;
$this->_eventManager = $Controller->getEventManager();
} else {
$this->_eventManager = new EventManager();
}
}
示例10: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', ['authorize' => ['Controller'], 'loginRedirect' => ['prefix' => false, 'controller' => 'Home', 'action' => 'index'], 'logoutRedirect' => ['prefix' => false, 'controller' => 'Users', 'action' => 'login']]);
}
示例11: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Crud.Crud', ['actions' => ['Crud.Index', 'Crud.View', 'Crud.Add', 'Crud.Edit', 'Crud.Delete'], 'listeners' => ['Crud.Api', 'Crud.ApiPagination', 'Crud.ApiQueryLog']]);
$this->loadComponent('Auth', ['storage' => 'Memory', 'authenticate' => ['Form' => ['scope' => ['Users.active' => 1], 'fields' => ['username' => 'email', 'password' => 'password']], 'ADmad/JwtAuth.Jwt' => ['parameter' => 'token', 'userModel' => 'Users', 'scope' => ['Users.active' => 1], 'fields' => ['username' => 'id'], 'queryDatasource' => true]], 'unauthorizedRedirect' => false, 'checkAuthIn' => 'Controller.initialize', 'authorize' => ['Controller']]);
}
示例12: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', ['authorize' => ['Controller'], 'authenticate' => ['Form' => ['fields' => ['username' => 'email', 'password' => 'password'], 'finder' => 'auth']], 'loginAction' => ['controller' => 'Users', 'action' => 'login'], 'authError' => 'Ingrese sus datos', 'loginRedirect' => ['controller' => 'Users', 'action' => 'home'], 'logoutRedirect' => ['controller' => 'Users', 'action' => 'login'], 'unauthorizedRedirect' => $this->referer()]);
}
示例13: initialize
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', ['authorize' => ['Controller'], 'loginRedirect' => ['controller' => 'Associations', 'action' => 'init'], 'logoutRedirect' => ['controller' => 'Pages', 'action' => 'home']]);
}
示例14: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', ['authenticate' => ['Form' => ['userModel' => 'Users']]]);
}
示例15: initialize
/**
* Initialization hook method.
*
* Use this method to add common initialization code like loading components.
*
* e.g. `$this->loadComponent('Security');`
*
* @return void
*/
public function initialize()
{
parent::initialize();
$this->loadComponent('RequestHandler');
$this->loadComponent('Flash');
$this->loadComponent('Auth', ['loginRedirect' => '/admin', 'authError' => 'Você possivelmente digitou suas credenciais erradas!', 'logoutRedirect' => ['prefix' => false, 'controller' => 'Pages', 'action' => 'display', 'home']]);
}