Phalcon处理404页面的 Ruter 方法

  /**
     * Initializes the router
     *
     * @param array $options
     */
    protected function initRouter($options = array())
    {
        $config = $this->di['config'];

        $this->di['router'] = function () use ($config) {

            $router = new PhRouter(false);

            $router->notFound(
                array(
                    "controller" => "index",
                    "action"     => "notFound",
                )
            );
            $router->removeExtraSlashes(true);

            foreach ($config['routes'] as $route => $items) {
                $router->add($route, $items->params->toArray())
                       ->setName($items->name);
            }

            return $router;
        };
    }
posted @ 2014-07-24 09:07  王默默  阅读(1426)  评论(0编辑  收藏  举报