Session::dispatch()

@return
556063
protected function dispatch()
    {
        switch ($this->config['driver']) {
            case 'file':
            default:
                $this->sessionHandler = new Store($this->config['cookie'], $this->fileHandler());
                break;
        }
        $name = $this->sessionHandler->getName();
        if (isset($_COOKIE[$name]) && $sessionId = $_COOKIE[$name]) {
            $this->sessionHandler->setId($sessionId);
        } elseif (!isset($_COOKIE[$name])) {
            setcookie($name, $this->getId(), time() + 60 * $this->config['lifetime'], $this->config['path'], $this->config['domain'], $this->config['secure'], $this->config['http_only']);
        }
        $this->sessionHandler->start();
        register_shutdown_function([$this, 'save']);
        $this->initiatePhpSession();
        $this->globalise();
        return $this;
    }
921630
public function dispatch()
	{
		if(!self::$isDispatched){
		    if (PHP_SAPI == 'cli') {
		        $this->dispatchCli();
		    } else {
                $this->dispatchHttp();
		    }
            self::$isDispatched = true;
        }
    }
549768
public function dispatch()
    {
        $this->lock->acquire();

        $this->guardThatHistoryRepositoryDoesNotHaveMoreUnitsOfWork();

        $workloadRepository = $this->sourceRepository->diff(
            $this->historyRepository
        );

        foreach ($workloadRepository as $unitOfWork) {
            $this->executeMigration($unitOfWork);
        }

        $this->historyRepository->persist();

        $this->lock->release();
    }
883110
private function dispatch($call)
    {

        $path = $call->getAction();
        $method = $call->getMethod();

        $matches = preg_split('/(?=[A-Z])/',$path);
        $route = strtolower(implode('/', $matches));
        $route .= "/".$method;

        $request = $this->app['request'];

        $files = $this->fixFiles($request->files->all());

        // create the route request
        $routeRequest = Request::create($route, 'POST', $call->getData(), $request->cookies->all(), $files, $request->server->all());

        if ('form' == $this->request->getCallType()) {
            $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST);

            $response = $call->getResponse($result);
        } else {
            try{
                $result = $this->app->handle($routeRequest, HttpKernelInterface::SUB_REQUEST);

                $response = $call->getResponse($result);
            }catch(\Exception $e){
                $response = $call->getException($e);
            }            
        }

        return $response;
    }
576120
public function dispatch()
    {
        $match = $this->match();

        if (class_exists($this->_controller_classname)) {
            $controller = $this->_controller_classname;
        } else {
            Cordillera::$exception = new Exception(
                translate('%s not found', [$this->_controller_classname]),
                500,
                Exception::ERROR
            );
            $controller = 'cordillera\\middlewares\\Controller';
        }

        $this->handler = '';

        if (isset($match['friendly']) && !$match['friendly']) {
            $this->handler = $match['handler'] ? $match['handler'] : $this->_default_route;
        } elseif (isset($match['friendly']) && $match['friendly']) {
            $this->handler = $match['handler'];
            $_GET = array_merge($_GET, $match['params']);
        } elseif (!isset($match['friendly'])) {
            $this->handler = ($match != '/' && $match != '') ? $match : $this->_default_route;
        }

        return new $controller($this);
    }
1017651
protected function dispatch()
    {
        $routeInfo = $this->createDispatcher()->dispatch($this->getHttpMethod(), $this->getUri());

        switch ($routeInfo[0]) {
            case Dispatcher::NOT_FOUND:
                throw new HttpException(404, 'NOT FOUND');
            case Dispatcher::METHOD_NOT_ALLOWED:
                // $allowedMethods = $routeInfo[1]; //允许的方法
                throw new HttpException(405, 'Method Not Allowed');
            case Dispatcher::FOUND:
                // $routeInfo = [Dispatcher::FOUND, 'handler', 'vars']
                break;
            default: //不会出现这种情况，这里运行不到
                throw new HttpException(404, 'NOT FOUND');
        }

        $this->parseRouteInfo($routeInfo[1], $routeInfo[2]);
    }
1033830
def dispatch(self):
    """"""
    try:
      webapp2.RequestHandler.dispatch(self)
    finally:
      self.session_store.save_sessions(self.response)
226325
public function dispatch($action, array $parameters = [])
    {
        return $this->server->dispatch(
            new Request($action, $parameters)
        )->getData();
    }
482970
def dispatch(self, *args, **kwargs):
        """"""
        action = kwargs.pop('action', 'default')
        action_method = getattr(self, str(action), self.default)
        return action_method(*args, **kwargs)
1034428
public function dispatch($object)
    {
        $handler = $this->commandTranslator->translate($object);

        return $this->app->make($handler)->handle($object);
    }
197543
def dispatch(self, receiver):
        ''' 

        '''
        super(SessionCallbackAdded, self).dispatch(receiver)
        if hasattr(receiver, '_session_callback_added'):
            receiver._session_callback_added(self)
576404
public function dispatch(Request $request)
	{
		if ($this->isDownForMaintenance())
		{
			$response = $this['events']->until('flyphp.app.down');

			if ( ! is_null($response)) return $this->prepareResponse($response, $request);
		}

		if ($this->runningUnitTests() && ! $this['session']->isStarted())
		{
			$this['session']->start();
		}

		return $this['router']->dispatch($this->prepareRequest($request));
	}
165398
public static function dispatch()
    {
        $uri = strtok($_SERVER["REQUEST_URI"],'?');
        $qs = parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY);
        $method = $_SERVER['REQUEST_METHOD'];
        
        
        foreach (self::$routes as $name=>$route) {


            $route  = self::parsePattern($route);

            $matched = array();
            if ($route=='' || preg_match('#' . $route . '#', $uri, $matched) && (self::$methods[$name] == 'ANY' || self::$methods[$name] == $method)) {
                
                array_shift($matched);

                if (self::$qs[$name]!='' && preg_match('#' . self::$qs[$name] . '#', $qs, $qsmatched)) {

                    array_shift($qsmatched);

                    $matched = array_merge($matched, $qsmatched);
                    self::$catched[] = $name;
                    BurpEvent::listen($name, self::$callbacks[$name]);
                    BurpEvent::queue($name, $matched);

                } elseif (self::$qs[$name] == '') {
                    self::$catched[] = $name;
                    BurpEvent::listen($name, self::$callbacks[$name]);
                    BurpEvent::queue($name, $matched);
                }
            }

        }

        //call missing if needed
        if (!is_null(self::$missing_callback) ) {
            $diff = array_diff(self::$tocatch, self::$catched);
            if (count($diff) >= count(self::$tocatch)) {
                call_user_func(self::$missing_callback);
                BurpEvent::listen('missing', self::$callbacks[$name]);
                BurpEvent::fire('missing');

            }

        }

        BurpEvent::flushAll();
    }
917542
public function dispatch(Request $request)
    {
        $this->currentRoute = null;

        $this->container->instance(Request::class, $request);

        $this->routesDispatched++;

        try {
            $response = $this->adapter->dispatch($request, $request->version());
        } catch (Exception $exception) {
            if ($request instanceof InternalRequest) {
                throw $exception;
            }

            $this->exception->report($exception);

            $response = $this->exception->handle($exception);
        }

        return $this->prepareResponse($response, $request, $request->format());
    }
808446
public function dispatch()
    {
        if (strtolower(Container::get('config')->get('url_mode')) == 'query_string') {
            $this->uri = explode('?', $this->uri, 2);
            $_SERVER['QUERY_STRING'] = isset($this->uri[1]) ? $this->uri[1] : '';
            $this->uri = $this->uri[0];
            parse_str($_SERVER['QUERY_STRING'], $_GET);
        }

        if ($this->uri == 'favicon.ico') {
            return Container::get('response')->setStatus(404);
        }

        Middleware::register('before_route');
        $parsedRoute = $this->parseRoutes($this->uri);
        Middleware::register('after_route');

        if ($parsedRoute) {
            $this->uri = $parsedRoute;
        } else {
            if (Container::get('request')->isOptions()) {
                Container::get('response')->setStatus(204);
                exit;
            }

            throw new RouteNotFoundException('Request URI ' . $this->uri . ' is not Matched by any route.');
        }

        $this->uris = ($this->uri != '') ? explode('/', trim($this->uri, '/')) : [];

        // Clean uris
        foreach ($this->uris as $key => $value) {
            if ($value == '') {
                unset($this->uris[$key]);
            }
        }

        $this->uris = array_merge($this->uris);

        $this->controller = $this->getController();
        $this->action = $this->getAction();

        // If is already initialized
        $prefix = Container::get('config')->get('namespace_prefix');

        $controllerClassName = $prefix . 'controllers\\' . $this->controller;

        Middleware::register('before_controller');

        if (isset($this->controllers[$this->controller])) {
            $class = $this->controllers[$this->controller];
        } else {
            $constructInstances = $this->getMethodInstances($controllerClassName);
            if (!$constructInstances) {
                $class = new $controllerClassName();
            } else {
                $reflect = new ReflectionClass($controllerClassName);
                $class = $reflect->newInstanceArgs($constructInstances);
            }

            $this->controllers[$this->controller] = $class;
        }

        Middleware::register('after_controller');

        if (!class_exists($controllerClassName)) {
            throw new NotFoundException('Request Controller ' . $this->controller . ' is not Found.');
        }

        if (!method_exists($class, $this->action)) {
            throw new NotFoundException('Request Action ' . $this->action . ' is not Found.');
        }

        $callback = [$class, $this->action];
        if (!is_callable($callback)) {
            throw new NotFoundException($controllerClassName . '::' . $this->action . '() is not callable');
        }

        // Parse params from uri
        $this->params = $this->getParams();

        // Do some final cleaning of the params
        $_GET = array_merge($this->params, $_GET);
        $_REQUEST = array_merge($_POST, $_GET, $_COOKIE);

        if (Container::get('config')->get('app_debug')) {
            Container::get('response')->setHeader('X-Kotori-Hash', call_user_func(function () {
                $lockFile = Helper::getComposerVendorPath() . '/../composer.lock';
                if (!Helper::isFile($lockFile)) {
                    return 'unknown';
                } else {
                    $lockData = file_get_contents($lockFile);
                    $lockData = json_decode($lockData, true);
                    foreach ($lockData['packages'] as $package) {
                        if ($package['name'] == 'kokororin/kotori-php') {
                            return substr($package['source']['reference'], 0, 6);
                        }
                    }
                }

                return 'unknown';
            }));
        }

        Middleware::register('before_action');
        // Call the requested method

        $methodInstances = $this->getMethodInstances($callback[0], $callback[1]);
        if (!$methodInstances) {
            $output = call_user_func_array($callback, $this->params);
        } else {
            $output = call_user_func_array($callback, $methodInstances);
        }

        Middleware::register('after_action');
        if (is_array($output)) {
            Container::get('response')->throwJSON($output);
        }
    }
1253622
public function dispatch() {
		while (true) {
			if ($this->_break) {
				break;
			}
			if ($this->_paused) {
				$this->_title('Paused, waiting');
				$this->_log->debug('Paused, waiting.');
			}
			while ($this->_paused) {
				pcntl_signal_dispatch();
				sleep($this->_interval);
			}

			$this->_title('Waiting for job');
			$this->_log->debug('Waiting for job.');

			while (!$this->_job) {
				// FIXME Catch exception. but only handler exceptions.
				$this->_job = $this->_connection->reserve($this->_queues, 5);
				pcntl_signal_dispatch();
			}
			$this->_title("Performing job {$this->_job}");
			$this->_log->debug("Performing job {$this->_job}.");

			try {
				if ($this->_job->perform()) {
					$this->_job->succeed();
				} else {
					$this->_job->fail();
				}
			} catch (Exception $e) {
				$this->_log->notice(get_class($e) . ' while performing job: ' . $e->getMessage());
				$this->_job->fail();
			}
			$this->_job = null;
		}
	}
881022
public function dispatch(Request $request)
    {
        $this->validate($request);

        return $this->next->dispatch($request);
    }