當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dispatcher::setControllerName方法代碼示例

本文整理匯總了PHP中Phalcon\Mvc\Dispatcher::setControllerName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dispatcher::setControllerName方法的具體用法?PHP Dispatcher::setControllerName怎麽用?PHP Dispatcher::setControllerName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Phalcon\Mvc\Dispatcher的用法示例。


在下文中一共展示了Dispatcher::setControllerName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUpDispatcher

 private function setUpDispatcher()
 {
     $this->dispatcher->setControllerName($this->router->getControllerName());
     $this->dispatcher->setActionName($this->router->getActionName());
     $this->dispatcher->setParams($this->router->getParams());
     $oDispatcherEventManager = new Manager();
     $oDispatcherEventManager->attach('dispatch:beforeDispatch', function (Event $oEvent, Dispatcher $oDispatcher, $data) {
         return false;
     });
     $this->dispatcher->setEventsManager($oDispatcherEventManager);
 }
開發者ID:rcmonitor,項目名稱:abboom_phalcon_code_example,代碼行數:11,代碼來源:DefaultDispatcherTest.php

示例2: beforeDispatchLoop

 public function beforeDispatchLoop($event, Dispatcher $dispatcher)
 {
     $resolver = di('resolver');
     $dispatcher->setControllerName($resolver->run('dispatch:controller', function () {
         $router = di('router');
         $moduleName = $router->getModuleName();
         $ctlName = ucfirst($router->getControllerName());
         return "\\App\\Modules\\{$moduleName}\\Controllers\\{$ctlName}";
     }));
 }
開發者ID:dotronglong,項目名稱:phalcon-engine,代碼行數:10,代碼來源:DispatchListener.php

示例3: setUp

 /**
  * Sets the test up by loading the DI container and other stuff
  *
  * @return Phalcon\DI
  */
 protected function setUp()
 {
     parent::setUp();
     // Set the dispatcher
     $this->di->set('dispatcher', function () {
         $dispatcher = new PhDispatcher();
         $dispatcher->setControllerName('test');
         $dispatcher->setActionName('empty');
         $dispatcher->setParams(array());
         return $dispatcher;
     });
     $this->di->set('escaper', function () {
         return new PhEscaper();
     });
 }
開發者ID:starsw001,項目名稱:cphalcon,代碼行數:20,代碼來源:FunctionalTestCase.php

示例4: setUp

 /**
  * Sets the test up by loading the DI container and other stuff
  *
  * @param  \Phalcon\DiInterface $di
  * @param  \Phalcon\Config      $config
  * @return void
  */
 protected function setUp(\Phalcon\DiInterface $di = null, \Phalcon\Config $config = null)
 {
     parent::setUp($di, $config);
     // Set the dispatcher
     $this->di->setShared('dispatcher', function () {
         $dispatcher = new PhDispatcher();
         $dispatcher->setControllerName('test');
         $dispatcher->setActionName('empty');
         $dispatcher->setParams(array());
         return $dispatcher;
     });
     $this->di->set('escaper', function () {
         return new PhEscaper();
     });
     if ($this->di instanceof \Phalcon\DiInterface) {
         $this->application = new PhApplication($this->di);
     }
 }
開發者ID:nejtr0n,項目名稱:incubator,代碼行數:25,代碼來源:FunctionalTestCase.php

示例5: setUp

 /**
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     // Set the dispatcher
     $this->di->setShared('dispatcher', function () {
         $dispatcher = new PhDispatcher();
         $dispatcher->setControllerName('test');
         $dispatcher->setActionName('empty');
         $dispatcher->setParams([]);
         return $dispatcher;
     });
     $this->di->set('escaper', function () {
         return new PhEscaper();
     });
     if ($this->di instanceof DiInterface) {
         $this->application = new PhApplication($this->di);
     }
 }
開發者ID:lisong,項目名稱:incubator,代碼行數:21,代碼來源:FunctionalTestCase.php

示例6: register

 /**
  * Initializes dispatcher
  */
 public function register()
 {
     $di = $this->getDi();
     $eventsManager = $this->getEventsManager();
     $config = $this->_config;
     $defaultModuleDir = $this->_module->getDefaultModuleDirectory();
     $di->set('defualtModuleDir', function () use($defaultModuleDir) {
         return $defaultModuleDir;
     });
     $moduleDirectory = $this->_module->getModuleDirectory();
     $di->set('moduleDirectory', function () use($moduleDirectory) {
         return $moduleDirectory;
     });
     $di->set('dispatcher', function () use($di, $eventsManager, $config) {
         // Create dispatcher
         $dispatcher = new MvcDispatcher();
         //Attach a listener
         $eventsManager->attach("dispatch:beforeException", function ($event, \Phalcon\Mvc\Dispatcher $dispatcher, $exception) use($di, $config) {
             if ($config->application->debug && $di->has('logger')) {
                 $logger = $di->get('logger');
                 $logger->error($exception->getMessage());
             }
             //Handle 404 exceptions
             if ($exception instanceof DispatchException) {
                 $dispatcher->forward(['controller' => 'error', 'action' => 'show404']);
                 return false;
             }
             if ($di->get('request')->isAjax() == true) {
             }
             //Handle other exceptions
             $dispatcher->forward(['controller' => 'error', 'action' => 'show503']);
             return false;
         });
         $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, \Phalcon\Mvc\Dispatcher $dispatcher) {
             $dispatcher->setControllerName(\Phalcon\Text::lower($dispatcher->getControllerName()));
         });
         $dispatcher->setEventsManager($eventsManager);
         return $dispatcher;
     });
 }
開發者ID:tashik,項目名稱:phalcon_core,代碼行數:43,代碼來源:Dispatcher.php

示例7: Router

<?php

/**
 * Created by PhpStorm.
 * User: rcmonitor
 * Date: 07.07.15
 * Time: 15:46
 */
use Phalcon\Di;
use Phalcon\Events\Manager;
use Phalcon\Mvc\Dispatcher;
use Phalcon\Mvc\Router;
use Phalcon\Version;
$di = new Di\FactoryDefault();
$oRouter = new Router(false);
$oRouter->setDI($di);
$oRouter->add('/:controller', array('controller' => 1, 'action' => 'index'));
$oEventManager = new Manager();
$oEventManager->attach('dispatch:beforeDispatch', function () {
    return false;
});
$oDispatcher = new Dispatcher();
$oDispatcher->setDI($di);
$oDispatcher->setEventsManager($oEventManager);
$oRouter->handle('/test');
$oDispatcher->setControllerName($oRouter->getControllerName());
$oDispatcher->setActionName($oRouter->getActionName());
$oDispatcher->dispatch();
echo $oDispatcher->getControllerClass() . PHP_EOL;
echo Version::get() . PHP_EOL;
開發者ID:rcmonitor,項目名稱:abboom_phalcon_code_example,代碼行數:30,代碼來源:discussion.php


注:本文中的Phalcon\Mvc\Dispatcher::setControllerName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。