Example #1
0
 /**
  * @brief 初始化MVC
  * @param \swoole_server $server
  * @param int $workerId
  */
 public function onWorkerStart(\swoole_server $server, $workerId)
 {
     parent::onWorkerStart($server, $workerId);
     define('APP_NAME', 'Application');
     define('APPLICATION_PATH', dirname(dirname(__DIR__)));
     $this->_objAha = \Aha\Bootstrap::getInstance(APP_NAME, 'product');
     $this->_objAha->setServer($server);
     $this->_objAha->getLoader()->registerNamespace(APP_NAME, APPLICATION_PATH);
     $this->_objAha->run();
     /**
     		$filter = new \Application\Filters\Track();
     		$this->_objAha->getFilter()
     				->registerPreRouter(array($filter, 'preRouterOne'))
     				->registerPreRouter(array($filter, 'preRouterTwo'))
     				->registerPostRouter(array($filter, 'postRouterOne'))
     				->registerPostRouter(array($filter, 'postRouterTwo'))
     				->registerPreDispatch(array($filter, 'preDispatchOne'))
     				->registerPreDispatch(array($filter, 'preDispatchTwo'))
     				->registerPostDispatch(array($filter, 'postDispatchOne'))
     				->registerPostDispatch(array($filter, 'postDispatchTwo'));
     */
 }
Example #2
0
File: Router.php Project: vucms/aha
 /**
  * @brief 迭代出actions目录的所有action文件 
  * 这样在做路由的时候 检测路由是hash操作 不会有文件检测的io操作 更高效更快速
  * @param \Aha\Mvc\Aha\Bootstrap $bootstrap
  */
 public static function loadActionPaths(\Aha\Bootstrap $bootstrap)
 {
     $appNamespace = $bootstrap->getAppNamespace();
     $appPath = $bootstrap->getLoader()->getPathByByNamespace($appNamespace);
     $actionPath = $appPath . DIRECTORY_SEPARATOR . $appNamespace . DIRECTORY_SEPARATOR . 'Actions';
     self::$_arrActions = array();
     $directoryIt = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($actionPath));
     $directoryIt->rewind();
     while ($directoryIt->valid()) {
         if (!$directoryIt->isDot() && substr($directoryIt->key(), -4) === AHA_EXT) {
             array_push(self::$_arrActions, substr($directoryIt->key(), 0, -strlen(AHA_EXT)));
         }
         $directoryIt->next();
     }
 }