Prepare the route instance for serialization.


@throws \LogicException
186995
public function prepareForSerialization()
	{
		if ( $this->action['uses'] instanceof Closure )
			throw new LogicException( "Unable to prepare route [{$this->uri}] for serialization. Uses Closure." );

		unset( $this->router, $this->bindings, $this->compiled );
	}
1025583
protected static function _prepare()
    {
        if (empty(static::$_module)) {
            $module = Module::getModuleByClassname(Module::className());
            if (!empty($module)) {
                static::$_sysControllerUid = "/sys/main";
                static::$_routeActionView = "/{$module->uniqueId}/main/view";
                static::$_routeActionShow = "/{$module->uniqueId}/main/show";
                static::$_model = $module::model(self::MODEL_ALIAS);
            }
        }
    }
804024
protected function initialize()
    {
        if ('textarea' !== $this->node->nodeName) {
            throw new \LogicException(sprintf('A TextareaFormField can only be created from a textarea tag (%s given).', $this->node->nodeName));
        }

        $this->value = '';
        foreach ($this->node->childNodes as $node) {
            $this->value .= $node->wholeText;
        }
    }
1199991
protected function init($filepath)
    {
        $this->file = new \SplFileObject($filepath);

        if (!$this->file->isFile()) {
            throw new \LogicException('This is not a file', 1);
        }

        if (!$this->file->isReadable()) {
            throw new \Exception('This file is not readable', 1);
        }

        if (!$this->file->isWritable()) {
            //throw new \Exception("This file is not writable", 1);
        }

        $this->filepath = $this->file->getPathName();
    }
268372
public function generateRoutesData(RouteParser $routeParser, DataGenerator $dataGenerator)
    {
        $routes = [];

        foreach ($this->routes as $name => $route) {
            if ($route['group']) {
                if (!isset($this->groups[$route['group']])) {
                    throw new \LogicException(sprintf(
                        'The route group "%s" is not found',
                        $route['group']
                    ));
                }
                $pattern = $this->groups[$route['group']][0] . $route['pattern'];
                $middlewares = array_merge($this->groups[$route['group']][1], $route['middlewares']);
            } else {
                $pattern = $route['pattern'];
                $middlewares = $route['middlewares'];
            }

            $routeDatas = $routeParser->parse($pattern);
            $this->addToDataGenerator($route['methods'], $routeDatas, $name, $dataGenerator);

            $routes[$name] = [
                'datas' => $routeDatas,
                'methods' => $route['methods'],
                'pattern' => $pattern,
                'middlewares' => $middlewares,
                'handler' => $route['handler'],
                'group' => $route['group']
            ];
        }

        return ['routes' => $routes, 'dispatch_data' => $dataGenerator->getData()];
    }
466166
protected function initTerra()
    {
        if (empty($this->mapSeed)) {
            $this->setMapSeed(microtime(true));
        }

        if (!$this->getPersistence()) {
            throw new LogicException('Persistence must be set');
        }

        if (!$this->getSize()) {
            throw new LogicException('Size must be set');
        }

        mt_srand($this->numericMapSeed * $this->persistence * $this->size);

        $this->terra = new SplFixedArray($this->size);
        for ($y = 0; $y < $this->size; $y++) {
            $this->terra[$y] = new SplFixedArray($this->size);
            for ($x = 0; $x < $this->size; $x++) {
                $this->terra[$y][$x] = 0;
            }
        }
    }
903754
protected function initializeForModelRoute()
    {
        $this->moduleKey        = $this->routeHelper->getModuleKeyForCurrentRoute();
        $this->modelSlug        = $this->routeHelper->getModelSlugForCurrentRoute();
        $this->permissionPrefix = $this->routeHelper->getPermissionPrefixForModelSlug($this->modelSlug);

        if ( ! $this->moduleKey) {
            // @codeCoverageIgnoreStart
            throw new RuntimeException("Could not determine module key for route");
            // @codeCoverageIgnoreEnd
        }

        $this->modelInformation = $this->infoRepository->getByKey($this->modelSlug);

        if ( ! $this->modelInformation) {
            // @codeCoverageIgnoreStart
            throw new RuntimeException("Could not load information for model key '{$this->modelSlug}'");
            // @codeCoverageIgnoreEnd
        }

        $this->routePrefix = $this->routeHelper->getRouteNameForModelClass(
            $this->modelInformation->modelClass(),
            true
        );

        return $this;
    }
471817
public function setParser(Parser $parser)
    {
        if (!empty($this->statics) || !empty($this->dynamics)) {
            throw new \LogicException("You can't define a route parser after registering a route.");
        }

        $this->parser = $parser;
        return $this;
    }
116359
protected function prepare () {
		$request = & $this->request;

		// store original path value for later use
		$request->SetOriginalPath($request->GetPath(TRUE));

		// switching media site version and targeting localized version 
		// will be only by GET method, other methods are not very useful 
		// to localize or target for media site version. It adds only another
		// not much useful route records to route processing:
		$this->isGet = $request->GetMethod() == \MvcCore\IRequest::METHOD_GET;
		
		// look into request params if there is any switching 
		// parameter for session strict mode
		$this->requestGlobalGet = array_merge([], $request->GetGlobalCollection('get')); // clone `$_GET`
		
		// Set up session object to look inside for something from previous requests. 
		// This command starts the session if not started yet.
		$this->setUpSession();

		// Try to recognize administration request by `admin` param in query string
		// and by any authenticated user. The boolean flag `$this->adminRequest`
		// is used only to not process strict session mode redirections and to serve
		// requested documents directly, so there is not necessary to check if user
		// has any privileges or not, because this is only router.
		if (isset($this->requestGlobalGet[static::$adminRequestQueryParamName])) {
			$authClass = static::$baseAuthClass;
			if (class_exists($authClass)) {
				$user = $authClass::GetInstance()->GetUser();
				if ($user !== NULL) 
					$this->adminRequest = TRUE;
			}
		}
	}
672864
public function prepare()
    {

        // prepare the context path
        $contextPath = str_replace($this->getContext()->getAppBase(), '', $this->getContext()->getWebappPath());

        // set the context path
        $this->setContextPath($contextPath);

        // Fixed #735 - Endless Loop for URLs without servlet name
        // Load the request URI and query string from the server vars, because we have to
        // take care about changes from other modules like directory or rewrite module!
        $uri = $this->getRequestUri();
        $queryString = $this->getQueryString();

        // get uri without querystring
        $uriWithoutQueryString = str_replace('?' . $queryString, '', $uri);

        // initialize the path information and the directory to start with
        list ($dirname, $basename, $extension) = array_values(pathinfo($uriWithoutQueryString));

        // make the registered handlers local
        $handlers = $this->getHandlers();

        // descent the directory structure down to find the (almost virtual) servlet file
        do {
            // bingo we found a (again: almost virtual) servlet file
            if (isset($handlers[".$extension"])) {
                // prepare the servlet path (we've to take care, because the
                // pathinfo() function converts / to \ on Windows OS
                if ($dirname === DIRECTORY_SEPARATOR) {
                    $servletPath = '/' . $basename;
                } else {
                    $servletPath = $dirname . '/' . $basename;
                }

                // we set the basename, because this is the servlet path
                $this->setServletPath($servletPath);

                // we set the path info, what is the request URI with stripped dir- and basename
                $this->setPathInfo(str_replace($servletPath, '', $uriWithoutQueryString));

                // we've found what we were looking for, so break here
                break;
            }

            // break if we finally can't find a servlet to handle the request
            if ($dirname === '/') {
                throw new ServletException(
                    sprintf('Can\'t find a handler for URI %s, either ', $uri)
                );
            }

            // descend down the directory tree
            list ($dirname, $basename, $extension) = array_values(pathinfo($dirname));

        } while ($dirname !== false); // stop until we reached the root of the URI

        // prepare and set the servlet path
        $this->setServletPath(str_replace($contextPath, '', $this->getServletPath()));

        // prepare the base modifier which allows our apps to provide a base URL
        $webappsDir = str_replace($this->getContext()->getBaseDirectory(), '', $this->getContext()->getAppBase());
        $relativeRequestPath = strstr($this->getDocumentRoot(), $webappsDir);
        $proposedBaseModifier = str_replace(DIRECTORY_SEPARATOR, '/', str_replace($webappsDir, '', $relativeRequestPath));

        //  prepare the base modifier
        if (strpos($proposedBaseModifier, $contextPath) === 0) {
            $this->setBaseModifier('');
        } else {
            $this->setBaseModifier($contextPath);
        }
    }
702824
protected function prepare() : void
    {
        if ($this->prepared) {
            return;
        }

        if ($this->cacheEnabled && file_exists($this->cacheFile)) {
            $this->loadFromCache();
            $this->prepared = true;
            return;
        }

        $routeCollector = new RouteCollector();
        $routeDefinitionCallback = $this->routeDefinitionCallback;
        $routeDefinitionCallback($routeCollector);

        $data = $routeCollector->generateRoutesData(
            new StdParser(),
            new DataGeneratorGroupCountBased()
        );
        $this->routes = $data['routes'];
        $this->dispatchData = $data['dispatch_data'];

        if ($this->cacheEnabled) {
            $this->saveToCache($data);
        }

        $this->prepared = true;
    }
494687
public function create()
    {
        $pdo = null;
        try {
            $pdo = $this->connect();
        } catch (\Exception $e) {
            $pdo = null;
            if ($this->isLostConnection($e)) {
                $pdo = $this->reconnect();
            }

            throw new \LogicException('Connection lost and no reconnector available.');
        }

        return $pdo;
    }
706469
public function toModel()
    {
        $nodeClass = $this->getElement()->NodeClass;
        if ($nodeClass === 'Node') {
            throw new LogicException('You must set a custom node in <node_class/> for element: ' . $this->getElement()->getSlug());
        } else {
            throw new LogicException('You must create a toModel method in: ' . $nodeClass);
        }
    }
983109
private function prepare()
    {
        try {
            $projectRoot = dirname(__DIR__, 4);
            if (!$this->router) {
                $this->useRoute($projectRoot . DIRECTORY_SEPARATOR . "route.json");
            }
            if (!$this->logDirectory) {
                $this->useLogger($projectRoot . DIRECTORY_SEPARATOR . "log");
            }
            $this->getErrorHandler()->register();
            unset($this->logDirectory);
        } catch (InvalidArgumentException $e) {
            throw new RuntimeException(
                "Can't prepare application: " . $e->getMessage());
        }
    }
198261
public function setName($name)
    {
        if (!is_string($name)) {
            throw new \LogicException(sprintf('Route name given "%s" is invalid. String expected.', gettype($name)));
        }
        $this->name = $name;
        
        return $this;
    }
1285100
public function prepare()
    {
        if ($this->ready) {
            return null;
        }

        $this->ready = true;

        $format     = $this->format;
        $controller = $this->controller;

        foreach ($this->classMethods as $value) {
            if ($format === self::BOTH || $format === self::SLASH) {
                $route = '/' . (empty($value[1]) ? '' : ($value[1] . '/'));

                Route::set($value[0], $route, $controller . ':' . $value[2]);
            }

            if ($format === self::BOTH || $format === self::NOSLASH) {
                $route = empty($value[1]) ? '' : ('/' . $value[1]);

                Route::set($value[0], $route, $controller . ':' . $value[2]);
            }
        }

        $controller = $classMethods = null;
    }
832370
private function prepare()
    {
        $this->uri = $this->getURI();
        $this->discoverRoute();
        $this->isURIClean();
        $this->currentURL = $this->baseURL($this->uri);
        $this->baseURL = $this->baseURL();
    }