src/Core/Application.php
public function dispatcher($router, $args = array(), $return_response_content = false)
    {
        $init_prams = true;
        $router = $this->parseRouter($router, $args, $init_prams);
        $cr = $this->initController($router['controller'], $router['action']);

        $closureContainer = $this->delegate->getClosureContainer();
        $annotate_config = $this->getAnnotateConfig();

        $action_params = array();
        if (isset($annotate_config['params'])) {
            $action_params = &$annotate_config['params'];
        }

        if ($init_prams) {
            $this->initParams($router['params'], $action_params);
        } elseif (is_array($router['params'])) {
            $params = $router['params'] + $action_params;
            $this->setParams($params);
        } else {
            $this->setParams($router['params']);
        }

        $closureContainer->run('dispatcher');

        if (!empty($annotate_config['basicAuth'])) {
            $this->delegate->getResponse()->basicAuth($annotate_config['basicAuth']);
        }

        $cache = false;
        if (isset($annotate_config['cache'])) {
            $cache = $this->initRequestCache($annotate_config['cache'], $action_params);
        }

        if ($cache && $cache->isValid()) {
            $response_content = $cache->get();
        } else {
            $action = $this->getAction();
            $controller_name = $this->getController();

            $runtime_config = array(
                'action_annotate' => $annotate_config,
                'view_controller_namespace' => $this->getViewControllerNameSpace($controller_name),
                'controller' => $controller_name,
                'action' => $action,
                'params' => $this->getParams(),
            );

            $closureContainer->add('~controller~runtime~', function () use (&$runtime_config) {
                return $runtime_config;
            });

            try {
                $cr->setStaticPropertyValue('app_delegate', $this->delegate);
                $controller = $cr->newInstance();
            } catch (Exception $e) {
                throw new CoreException($e->getMessage(), 200, $e);
            }

            if ($this->delegate->getResponse()->isEndFlush()) {
                return true;
            }

            if (isset($annotate_config['before'])) {
                $this->callReliesControllerClosure($annotate_config['before'], $controller);
            }

            if ($this->ob_cache_status) {
                ob_start();
                $response_content = $controller->$action();
                if (!$response_content) {
                    $response_content = ob_get_contents();
                }
                ob_end_clean();
            } else {
                $response_content = $controller->$action();
            }

            if ($cache) {
                $cache->set($response_content);
            }
        }

        if (!empty($annotate_config['response'])) {
            $this->setResponseConfig($annotate_config['response']);
        }

        if ($return_response_content) {
            return $response_content;
        } else {
            $this->delegate->getResponse()->display($response_content);
        }

        if (isset($annotate_config['after']) && isset($controller)) {
            $this->callReliesControllerClosure($annotate_config['after'], $controller);
        }

        return true;
    }
public function dispatcher($router, $args = array(), $return_response_content = false)
    {
        $init_prams = true;
        $router = $this->parseRouter($router, $args, $init_prams);
        $cr = $this->initController($router['controller'], $router['action']);

        $closureContainer = $this->delegate->getClosureContainer();
        $annotate_config = $this->getAnnotateConfig();

        $action_params = array();
        if (isset($annotate_config['params'])) {
            $action_params = &$annotate_config['params'];
        }

        if ($init_prams) {
            $this->initParams($router['params'], $action_params);
        } elseif (is_array($router['params'])) {
            $params = $router['params'] + $action_params;
            $this->setParams($params);
        } else {
            $this->setParams($router['params']);
        }

        $closureContainer->run('dispatcher');

        if (!empty($annotate_config['basicAuth'])) {
            $this->delegate->getResponse()->basicAuth($annotate_config['basicAuth']);
        }

        $cache = false;
        if (isset($annotate_config['cache'])) {
            $cache = $this->initRequestCache($annotate_config['cache'], $action_params);
        }

        if ($cache && $cache->isValid()) {
            $response_content = $cache->get();
        } else {
            $action = $this->getAction();
            $controller_name = $this->getController();

            $runtime_config = array(
                'action_annotate' => $annotate_config,
                'view_controller_namespace' => $this->getViewControllerNameSpace($controller_name),
                'controller' => $controller_name,
                'action' => $action,
                'params' => $this->getParams(),
            );

            $closureContainer->add('~controller~runtime~', function () use (&$runtime_config) {
                return $runtime_config;
            });

            try {
                $cr->setStaticPropertyValue('app_delegate', $this->delegate);
                $controller = $cr->newInstance();
            } catch (Exception $e) {
                throw new CoreException($e->getMessage(), 200, $e);
            }

            if ($this->delegate->getResponse()->isEndFlush()) {
                return true;
            }

            if (isset($annotate_config['before'])) {
                $this->callReliesControllerClosure($annotate_config['before'], $controller);
            }

            if ($this->ob_cache_status) {
                ob_start();
                $response_content = $controller->$action();
                if (!$response_content) {
                    $response_content = ob_get_contents();
                }
                ob_end_clean();
            } else {
                $response_content = $controller->$action();
            }

            if ($cache) {
                $cache->set($response_content);
            }
        }

        if (!empty($annotate_config['response'])) {
            $this->setResponseConfig($annotate_config['response']);
        }

        if ($return_response_content) {
            return $response_content;
        } else {
            $this->delegate->getResponse()->display($response_content);
        }

        if (isset($annotate_config['after']) && isset($controller)) {
            $this->callReliesControllerClosure($annotate_config['after'], $controller);
        }

        return true;
    }
运行框架

@param object|string $router
@param array|string $args 指定参数
@param bool $return_response_content 是否输出执行结果
@return array|mixed|string
@throws CoreException