FOF30\Dispatcher\Dispatcher::dispatch PHP 메소드

dispatch() 공개 메소드

The main code of the Dispatcher. It spawns the necessary controller and runs it.
public dispatch ( ) : void
리턴 void
    public function dispatch()
    {
        // Load the translations for this component;
        $this->container->platform->loadTranslations($this->container->componentName);
        // Perform transparent authentication
        $this->transparentAuthenticationLogin();
        // Get the event names (different for CLI)
        $onBeforeEventName = 'onBeforeDispatch';
        $onAfterEventName = 'onAfterDispatch';
        if ($this->container->platform->isCli()) {
            $onBeforeEventName = 'onBeforeDispatchCLI';
            $onAfterEventName = 'onAfterDispatchCLI';
        }
        try {
            $result = $this->triggerEvent($onBeforeEventName);
            $error = '';
        } catch (\Exception $e) {
            $result = false;
            $error = $e->getMessage();
        }
        if ($result === false) {
            if ($this->container->platform->isCli()) {
                $this->container->platform->setHeader('Status', '403 Forbidden', true);
            }
            $this->transparentAuthenticationLogout();
            throw new AccessForbidden();
        }
        // Get and execute the controller
        $view = $this->input->getCmd('view', $this->defaultView);
        $task = $this->input->getCmd('task', 'default');
        if (empty($task)) {
            $task = 'default';
            $this->input->set('task', $task);
        }
        $this->controller = $this->container->factory->controller($view, $this->config);
        $status = $this->controller->execute($task);
        if ($status !== false) {
            try {
                $this->triggerEvent($onAfterEventName);
            } catch (\Exception $e) {
                $status = false;
            }
        }
        if ($status === false) {
            if ($this->container->platform->isCli()) {
                $this->container->platform->setHeader('Status', '403 Forbidden', true);
            }
            $this->transparentAuthenticationLogout();
            throw new AccessForbidden();
        }
        $this->transparentAuthenticationLogout();
        $this->controller->redirect();
    }