Load user defined routes

By default this will load `config/routes.php`.

@since   1.0
@return  bool True is file is loaded else false.
492818
private function routes()
    {
        if (Configuration::read('routing.config.enable') === true) {
            $routingConfigPath = $this->configDir . DS . Configuration::read('routing.config.file');
            if (file_exists($routingConfigPath)) {
                require $routingConfigPath;
                return true;
            } else {
                throw new \Exception('Routing configuration file "' . $routingConfigPath . '" doesn\' exist.');
            }
        }
        return false;
    }
877078
public function loadBreadcrumbs()
    {
        if (!$this->config('breadcrumbs')) {
            return false;
        }

        $file = sprintf('%s/%s/%s',
            $this->basePath,
            $this->convention->routesFolder(),
            'breadcrumbs.php'
        );

        if (file_exists($file)) {
            require $file;
        }
    }
567851
protected function load()
	{
		static::$last = array('name' => $this->view, 'path' => $this->path);

		if (isset(static::$cache[$this->path]))
		{
			return static::$cache[$this->path];
		}
		else
		{
			return static::$cache[$this->path] = file_get_contents($this->path);
		}
	}
267852
private function load()
    {
        if (! isset($this->runtime_file_content)) {
            $this->runtime_file_content = json_decode(@file_get_contents($this->getFilePath()), true);
        }

        return $this->runtime_file_content;
    }
1223542
public function load()
    {
        // Make the $menu variable available to all files
        $menu = app('menu');

        // Include menu files
        $files = $this->getFiles();

        /** @var \SplFileInfo $file */
        foreach ($files as $file) {
            require_once $file->getPath() . '/' . $file->getFilename();
        }
    }
326038
protected function loadRoutes()
    {
        if (($routes = $this->app['config']['http.routes']) == null) {
            return;
        }

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

        $namespace = $this->getNamespace();

        foreach ($routes as $route) {
            if ($route instanceof Closure) {
                // We can defined routes with a Closure.
                call_user_func($route, $router);

                continue;
            }

            $attributes = $this->normalizeRouteAttributes($route);

            $filePath = array_pull($attributes, 'path');

            if ($namespace) {
                $attributes['namespace'] = $this->getGroupRouteNamespace($namespace, $attributes);
            }

            if (file_exists($filePath)) {
                $router->group($attributes, function ($router) use ($filePath) {
                    include $filePath;
                });
            }
        }
    }
754110
public function loadRoutes()
	{
		if ($this->bound('router')) {
			/**
			 * Use Cached Routes if Available
			 */

			if ($this['config']->get('routes.cache') && $this['files']->exists($this['config']->get('routes.compiled'))) {
				$contents = $this['files']->get($this['config']->get('routes.compiled'));
				if (!empty($contents)) {
					//Get Cached Routes & Set Them
					$this['router']->setRoutes(unserialize(base64_decode($contents)));
				}
			} else {
				//Assign Router to Simple Variable for Include
				$route = $this['router'];
				$response = $this['response'];
				//Include Routes
				if($this['files']->exists($this->base_path . '/app/Http/routes.php')){

					require_once $this->base_path . '/app/Http/routes.php';
				}
			}
			/**
			 * Store Cached Routes
			 */
			if ($this['config']->get('routes.cache') && !$this['files']->exists($this['config']->get('routes.compiled'))) {
				try {
					//Set Routes Cache
					if (!$this['files']->exists($this['config']->get('routes.compiled'))) {
						$allRoutes = $this['router']->getRoutes();
						//If Routes then Serialize
						if (count($allRoutes) > 0) {
							foreach ($allRoutes as $routeObject) {
								$routeObject->prepareForSerialization();
							}
						}
						//Store Routes in Cache
						$this['files']->put($this['config']->get('routes.compiled'), base64_encode(serialize($allRoutes)));
					}
				} catch (\Exception $exception) {
					if (!empty($exception->getMessage())) {
						add_action('admin_notices', function () use ($exception) {
							?>
							<div class="error notice">
								<p>&#9888; <?php echo $exception->getMessage(); ?></p>
								<p><em><? echo 'Route caching cannot serialize closures'; ?>.</em></p>
							</div>
							<?php
						});
					}
				}
			}
		}
	}
884431
public function isRouteAllowed()
	{
		return $this->_redirected || in_array(Request::getRequestMethod(), $this->getRoute()->getMethods()) === true;
	}
725897
protected function loadWebsocketRoutes()
    {
        $routePath = $this->container->make('config')
            ->get('swoole_websocket.route_file');

        if (! file_exists($routePath)) {
            $routePath = __DIR__ . '/../../routes/websocket.php';
        }

        return require $routePath;
    }
868246
public function init(): bool
    {
        // Sets the protected $_url
        $this->_getUrl();

        // Load the default Controller if no URL is set
        // eg: Visit http://localhost it loads Default Controller
        if (empty($this->_url[0])) {
            $this->_loadDefaultController();

            return false;
        }

        $this->_loadExistingController();
        $this->_callControllerMethod();

        return true;
    }
1277100
public function load()
    {
        if (! file_exists($file = $this->getFileName())) {
            return collect();
        }

        return collect(json_decode(file_get_contents($file), true));
    }
22957
private function routable() : bool
  {
    $routesFolder = config('app.dir') . 'routes' . DIRECTORY_SEPARATOR;

    if (!file_exists($routesFolder . 'api.php' )) {
      $this->exception('Could not find api routes.');
      return false;
    }

    if (!file_exists($routesFolder . 'web.php' )) {
      $this->exception('Could not find web routes.');
      return false;
    }

    return true;
  }
595852
public function requiresHttps(): bool
    {
        if ($this->requiresHttps) {
            return true;
        }

        $this->requiresHttps = $this->routingAnnotations()->requiresHttps();
        return $this->requiresHttps;
    }
105021
public function inAutoload()
    {
        $path = INPHINIT_PATH . 'boot/namespaces.php';
        $i = 0;

        if (is_file($path)) {
            $data = include $path;

            if (is_array($data)) {
                $this->libs = new \ArrayIterator($data + $this->libs->getArrayCopy());
            }

            return count($this->libs);
        }

        return false;
    }
1163266
public static function loadWfInOne()
    {
        if (static::$isWfInOneLoaded) {
            return true;
        }

        $inOneFile = ROOT_DIR . '/data/temp/wf_main_in_one.php';

        if (is_file($inOneFile) && date('Y-m-d', filemtime($inOneFile)) == date('Y-m-d')) {
            static::$isWfInOneLoaded = include_once $inOneFile;
            return static::$isWfInOneLoaded;
        }

        if (!is_writeable(dirname($inOneFile))) {
            return false;
        }

        // 待合并预加载的类
        $libClasses = [
            // app
            '\\wf\\app\\ApplicationAbstrct',
            '\\wf\\app\\Benchmark',
            '\\wf\\app\\Config',
            '\\wf\\app\\Hook',
            '\\wf\\app\\HookInterface',
            '\\wf\\app\\I18n',
            '\\wf\\app\\Object',
            '\\wf\\app\\ServiceLocator',
            '\\wf\\app\\Session',
            '\\wf\\app\\Version',

            // mvc
            '\\wf\\app\\web\\Application',
            '\\wf\\app\\web\\Controller',
            '\\wf\\app\\web\\Dispatcher',
            '\\wf\\app\\web\\Message',
            '\\wf\\app\\web\\Output',
            '\\wf\\app\\web\\Request',
            '\\wf\\app\\web\\Response',
            '\\wf\\route\\RouteAbstract',
            '\\wf\\route\\adapter\\Simple',
            '\\wf\\model\\Model',
            '\\wf\\model\\Error',
            '\\wf\\template\\EngineInterface',
            '\\wf\\template\\adapter\\Wind',

            // cache
            '\\wf\\cache\\CacheInterface',
            '\\wf\\cache\\CacheAbstract',
            '\\wf\\cache\\adapter\\File',
            '\\wf\\cache\\adapter\\Memcache',
            '\\wf\\cache\\adapter\\Memcached',
            '\\wf\\cache\\adapter\\Redis',

            // db
            '\\wf\\db\\DBInterface',
            '\\wf\\db\\DBAbstract',
            '\\wf\\db\\Finder',
            '\\wf\\db\\QueryBuilder',
            '\\wf\\db\\adapter\\MySQLi',
            '\\wf\\db\\adapter\\PDOMySQL',

            // logger
            '\\wf\\logger\\LoggerInterface',
            '\\wf\\logger\\LoggerAbstract',
            '\\wf\\logger\\adapter\\File',
        ];

        $liteContent = "<?php\n";

        foreach ($libClasses as $class) {
            $file = static::getClassFile($class);
            if (!$file) {
                continue;
            }

            // 类文件源码内容
            $clsCode = file_get_contents($file);
            $clsCode = clearSourceToken($clsCode, [T_COMMENT, T_DOC_COMMENT, T_INCLUDE_ONCE, T_REQUIRE_ONCE]); // 清空注释、require_once、include_once
            $clsCode = substr(trim($clsCode), 5); // 去掉文件开头的 <?php
            $clsCode = trim($clsCode);

            // 去掉php结束符 ？>
            if (substr($clsCode, -2) == '?>'){
                $clsCode = substr($clsCode, 0, -2);
            }

            // 处理namespace
            if(strpos($clsCode,'namespace ') === 0) {
                $clsCode = preg_replace('/namespace\s+(.*?);/','namespace \\1{', $clsCode, 1);
            } else {
                $clsCode = 'namespace {' . $clsCode;
            }
            $clsCode .= '}';

            //$liteContent .= "\n# {$class}\n". $clsCode;
            $liteContent .= $clsCode;
        }

        // 处理空行、空格
        $sourceLineArr = explode("\n", $liteContent);
        foreach ($sourceLineArr as $lineNumber => $lineText) {
            // 去掉前后空格
            $lineText = trim($lineText);

            // 去掉空行
            if (strlen($lineText) == 0) {
                unset($sourceLineArr[$lineNumber]);
                continue;
            }

            // 多个连续空格保留一个
            $lineText = preg_replace("/\s+/", ' ', $lineText);
            $sourceLineArr[$lineNumber] = $lineText;
        }
        $liteContent = implode("\n", $sourceLineArr);

        if(file_put_contents($inOneFile, $liteContent)) {
            static::$isWfInOneLoaded = include_once $inOneFile;
            return static::$isWfInOneLoaded;
        }

        return false;
    }
185955
public function load()
    {
        // We only care about GET requests at the moment
        if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
            return;
        }

        $file = $_SERVER['REQUEST_URI'] . 'index.html';
        if (is_file($this->destination . $file)) {
            $contents = file_get_contents($this->destination . $file);
            do_action('staticwp_pre_cache_hit', $_SERVER['REQUEST_URI']);
            echo apply_filters('staticwp_cache_hit_contents', $contents);
            do_action('staticwp_post_cache_hit', $_SERVER['REQUEST_URI']);
            exit();
        } else {
            do_action('staticwp_cache_miss', $_SERVER['REQUEST_URI']);
        }
    }
395739
public function load_config() {
        $cfg = [];
        require __DIR__ . '/defaults.php';
        if (file_exists($this->config_path)) {
            require $this->config_path;
        }
        $this->data = $cfg;
    }