本文整理汇总了PHP中Cake\Controller\Controller类的典型用法代码示例。如果您正苦于以下问题:PHP Controller类的具体用法?PHP Controller怎么用?PHP Controller使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Controller类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:dereuromark,项目名称:cakephp-cache,代码行数:12,代码来源:CacheComponentTest.php
示例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');
}
开发者ID:KarimaLadhani,项目名称:cakephp,代码行数:15,代码来源:ComponentTest.php
示例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();
}
开发者ID:josbeir,项目名称:cakephp-json-api,代码行数:12,代码来源:JsonApiViewTest.php
示例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());
}
}
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:12,代码来源:ComponentRegistry.php
示例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()));
}
开发者ID:dereuromark,项目名称:cakephp-tools,代码行数:13,代码来源:ControllerTest.php
示例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']]);
}
开发者ID:portsign,项目名称:produksatu,代码行数:16,代码来源:AppController.php
示例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']]);
}
开发者ID:Custodia,项目名称:caketickets,代码行数:16,代码来源:AppController.php
示例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();
}
开发者ID:ricardohenriq,项目名称:shooping,代码行数:14,代码来源:AppController.php
示例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();
}
}
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:14,代码来源:ComponentRegistry.php
示例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']]);
}
开发者ID:AdBouli,项目名称:hotel-manager,代码行数:16,代码来源:AppController.php
示例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']]);
}
开发者ID:chrisshick,项目名称:app,代码行数:16,代码来源:AppController.php
示例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()]);
}
开发者ID:edsonmgoz,项目名称:pocake,代码行数:16,代码来源:AppController.php
示例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']]);
}
开发者ID:raguilar0,项目名称:TCU_FEUCR,代码行数:7,代码来源:AppController.php
示例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']]]);
}
开发者ID:mattford,项目名称:Coordino,代码行数:16,代码来源:AppController.php
示例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']]);
}
开发者ID:richellyitalo,项目名称:estudoscakephp,代码行数:16,代码来源:AppController.php
示例16: setLanguage
/**
* Set the language for the user.
*
* @return void
*/
public function setLanguage()
{
if ($this->_controller->Auth->user()) {
//The user has already a valid language defined in the database.
if ($this->_session->read('Auth.User.language') && isset($this->_locales[$this->_session->read('Auth.User.language')])) {
//If the user has not the cookie, we set the cookie.
if (!$this->_cookie->check('language') || $this->_cookie->read('language') != $this->_session->read('Auth.User.language')) {
$this->_cookie->write('language', $this->_session->read('Auth.User.language'));
}
//Stock the locale of the user.
$this->_locale = $this->_session->read('Auth.User.language');
}
} else {
//The user has a valid cookie.
if ($this->_cookie->check('language') && isset($this->_locales[$this->_cookie->read('language')])) {
$this->_locale = $this->_cookie->read('language');
}
}
//The user want to change his language.
if (isset($this->_controller->request->params['lang']) && isset($this->_locales[$this->_controller->request->params['lang']])) {
//If the user is connected, we need to save the new language in the database and refresh his session.
if ($this->_controller->Auth->user()) {
$this->_controller->loadModel('Users');
$user = $this->_controller->Users->find()->where(['id' => $this->_session->read('Auth.User.id')])->first();
$user->language = $this->_controller->request->params['lang'];
$this->_controller->Users->save($user);
$this->_session->write('Auth.User.language', $this->_controller->request->params['lang']);
}
//Save the new language in the cookie.
$this->_cookie->write('language', $this->_controller->request->params['lang']);
$this->_locale = $this->_controller->request->params['lang'];
}
//Set the locale.
I18n::locale($this->_locale);
}
开发者ID:Xety,项目名称:Xeta,代码行数:40,代码来源:Language.php
示例17: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
//$this->Auth->allow(['view', 'index', 'checkExistence', 'edit',
//'delete', 'add', 'twit', 'twit1', 'mention','token', 'getMention', 'mentionToDB']);
$this->Auth->allow(['token', 'getMention']);
}
开发者ID:aansubarkah,项目名称:apimiminmacetdimana,代码行数:7,代码来源:AppController.php
示例18: 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' => ['controller' => 'Articles', 'action' => 'index'], 'logoutRedirect' => ['controller' => 'Pages', 'action' => 'display', 'home']]);
}
开发者ID:LoRayZm,项目名称:thevintagevault,代码行数:16,代码来源:AppController.php
示例19: _createSitemap
protected function _createSitemap($type)
{
$this->_type = $type;
//$this->controller->autoRender = false;
$this->controller->viewClass = 'Sitemap.SitemapXml';
$this->controller->viewBuilder()->autoLayout(false);
//@TODO Set response parameters from SitemapXml view
$this->controller->response->type('application/xml');
$this->controller->response->cache(mktime(0, 0, 0, date('m'), date('d'), date('Y')), $this->cache);
}
开发者ID:geo-poland,项目名称:cakephp3-sitemap,代码行数:10,代码来源:SitemapComponent.php
示例20: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->Auth->config('authError', "Désolé, vous n'êtes pas autorisés à accéder à cette zone.");
$this->Auth->allow(['add', 'login']);
$this->set('dataUser', $this->Auth->user());
}
开发者ID:yao-dev,项目名称:blog-mvc.github.io,代码行数:7,代码来源:AppController.php
注:本文中的Cake\Controller\Controller类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论