Pass unhandled URLs to the CMS Controller, if it exists

@param string $url
@return Response
973697
protected function passToCmsController($url)
    {
        if (class_exists('\Cms\Classes\Controller')) {
            return App::make('Cms\Classes\Controller')->run($url);
        } else {
            return Response::make(View::make('backend::404'), 404);
        }
    }
564457
private function get($url, Array $params = []) {
        $this->processor->get($url, $params);
        return $this->handleResponse();
    }
1245361
public function buildUrl($url)
    {
        if (strncmp($url, '/', 1) === 0) {
            return $url;
        }
        $baseUrl = isset($this->grid->controllerUrl) ? $this->grid->controllerUrl : '';

        return $baseUrl ? Url::to($baseUrl . '/' . $url) : Url::to($url);
    }
1296235
public function handleRequest($requestedUrl) {
        $controllersToScan = self::$config["scanneableControllers"];
        $request = HttpRequestBuilder::buildFromRequestUrl($requestedUrl);

        /* check mode */
        if ($this->getMode() != self::$MODE_TESTING) {

            /* session start when not testing */
            Session::start();

            /* lang config */
            if (!is_null($request->getLang())) {
                Session::set("lang", $request->getLang());
            } else {
                if (is_null(Session::get("lang")) && !is_null(self::get("lang", "default"))) {
                    Session::set("lang", self::get("lang", "default"));
                }
            }
        }

        // scan controller
        $enabledController = FALSE;
        foreach ($controllersToScan as $appName => $controllerNamespace) {
            $class = $controllerNamespace . $request->getControllerClass();
            if ($this->validClass($class)) {
                $enabledController = TRUE;
                break;
            }
        }

        if ($enabledController) {
            $controller = new $class();
            $controller->setName($request->getControllerName());
        } else {

            $class = self::get("defaultController");
            $request->setAction(self::get("defaultMethod"));
            $controller = new $class();
        }

        /* controller security */
        if ($controller->isSecure()) {

            /* check authenticated */
            if (is_null(Session::get("user"))) {

                /* route to login screen */
                $request = new HttpRequest("");
                $request->setAction(self::get("loginMethod"));
                $class = self::get("loginController");
                $controller = new $class();
            } else {

                /* check permissions */
                if (!$controller->canAccess(Session::get("user"))) {
                    $request = new HttpRequest("");
                    $request->setAction(self::get("restrictedMethod"));
                    $request->setControllerName("user");
                    $class = self::get("defaultController");
                    $controller = new $class();
                }
            }
        }
        $method = $request->getAction();
        $this->dispatch($controller, $method, $request);
    }
219243
public function url(string $url) : self
    {
        $this->route = $url;

        $this->active($url);

        return $this;
    }
91748
public function show($url)
    {
        $page = $this->repository->findPagesByURL($url);

        if (empty($page)) {
            abort(404);
        }

        return view('cms-frontend::pages.'.$page->template)->with('page', $page);
    }
781492
public static function mvc($url = '') {
		$result = array(
			'controller' => '',
			'controller_extension' => '',
			'action' => '',
			'post_action' => [],
			'id' => 0,
			'controllers' => [],
		);
		// remove an extra backslashes from left side
		$request_uri = explode('?', trim($url, '/'));
		$request_uri = $request_uri[0];
		// determine action and controller
		$parts = explode('/', $request_uri);
		// virtual controller
		if (substr($parts[0], 0, 2) == '__') {
			$virtual_object = new \Object\Virtual\Controllers();
			$virtual_data = $virtual_object->get();
			$key = substr($parts[0], 2);
			if (isset($virtual_data[$key])) {
				$temp = $parts;
				unset($temp[0]);
				$parts = explode('/', trim($virtual_data[$key]['no_virtual_controller_path'], '/'));
				foreach ($temp as $v) {
					$parts[] = $v;
				}
			}
		}
		$flag_action_found = false;
		foreach ($parts as $v) {
			if ($v . '' == '') {
				continue;
			}
			if ($flag_action_found) {
				$result['post_action'][] = $v;
				continue;
			}
			if (isset($v[0]) && $v[0] == '_' && !$flag_action_found) {
				$flag_action_found = true;
				$result['action'] = substr($v, 1);
				continue;
			}
			if (!$flag_action_found) {
				$result['controllers'][] = $v;
			} else {
				$result['post_action'][] = $v;
			}
			if ($flag_action_found) {
				if (is_numeric($v)) {
					$result['id'] = $v;
				}
				$result['post_action'][] = $v;
			}
		}
		// set default values for action and controller
		if (empty($result['controllers'])) {
			$result['controllers'][] = 'Index';
		} else {
			// processing controller extension
			end($result['controllers']);
			$key = key($result['controllers']);
			$last = $result['controllers'][$key];
			if (strpos($last, '.')) {
				$temp = explode('.', $last);
				$result['controllers'][$key] = $temp[0];
				unset($temp[0]);
				$result['controller_extension'] = implode('.', $temp);
			}
		}
		$result['controller'] = '/' . implode('/', $result['controllers']);
		$result['controller'] = str_replace('_', '/', $result['controller']);
		if (empty($result['action'])) {
			$result['action'] = 'Index';
		}
		// full string
		$result['full'] = $result['controller'] . '/_' . $result['action'];
		$result['full_with_host'] = rtrim(\Request::host(), '/') . $result['controller'] . '/_' . $result['action'];
		return $result;
	}
1370762
protected function _makeCurlRequest($url)
    {
        $curl_handle = curl_init($url);

        curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->_requestMethod);
        if($this->_requestBody)
        {
            curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->_requestBody);
        }

        curl_setopt($curl_handle, CURLOPT_HEADER, true);
        curl_setopt($curl_handle, CURLOPT_USERAGENT, $this->_requestUserAgent);
        curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl_handle, CURLOPT_COOKIE, $this->_buildProxyRequestCookieString());
        curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $this->_generateProxyRequestHeaders());

        $response = curl_exec($curl_handle);

        if (false === $response) {
            var_dump(curl_error($curl_handle));
        } else {
            return $response;
        }
    }
25025
public function load($url)
    {
        $masterRequest = $this->requestStack->getMasterRequest();
        $request = Request::create($url, 'GET', array(), $masterRequest->cookies->all(), array(), $masterRequest->server->all());
        if ($masterRequest->getSession()) {
            $request->setSession($masterRequest->getSession());
        }

        $response = $this->kernel->handle($request, HttpKernelInterface::SUB_REQUEST, false);

        return $response->getContent();
    }
981034
protected function urlParts(string $url)
    {
        if (false === filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED)) {
            return false;
        }
        return parse_url($url) ?: false;
    }
196414
public function findByUrl($url)
    {
        $this->url = $url;
        $url = RouterHelper::normalizeUrl($url);

        /**
         * @event cms.router.beforeRoute
         * Fires before the CMS Router handles a route
         *
         * Example usage:
         *
         *     Event::listen('cms.router.beforeRoute', function ((string) $url, (\Cms\Classes\Router) $thisRouterInstance) {
         *         return \Cms\Classes\Page::loadCached('trick-theme-code', 'page-file-name');
         *     });
         *
         */
        $apiResult = Event::fire('cms.router.beforeRoute', [$url, $this], true);
        if ($apiResult !== null) {
            return $apiResult;
        }

        for ($pass = 1; $pass <= 2; $pass++) {
            $fileName = null;
            $urlList = [];

            $cacheable = Config::get('cms.enableRoutesCache');
            if ($cacheable) {
                $fileName = $this->getCachedUrlFileName($url, $urlList);
                if (is_array($fileName)) {
                    list($fileName, $this->parameters) = $fileName;
                }
            }

            /*
             * Find the page by URL and cache the route
             */
            if (!$fileName) {
                $router = $this->getRouterObject();
                if ($router->match($url)) {
                    $this->parameters = $router->getParameters();

                    $fileName = $router->matchedRoute();

                    if ($cacheable) {
                        if (!$urlList || !is_array($urlList)) {
                            $urlList = [];
                        }

                        $urlList[$url] = !empty($this->parameters)
                            ? [$fileName, $this->parameters]
                            : $fileName;

                        $key = $this->getUrlListCacheKey();
                        Cache::put(
                            $key,
                            base64_encode(serialize($urlList)),
                            Config::get('cms.urlCacheTtl', 1)
                        );
                    }
                }
            }

            /*
             * Return the page
             */
            if ($fileName) {
                if (($page = Page::loadCached($this->theme, $fileName)) === null) {
                    /*
                     * If the page was not found on the disk, clear the URL cache
                     * and repeat the routing process.
                     */
                    if ($pass == 1) {
                        $this->clearCache();
                        continue;
                    }

                    return null;
                }

                return $page;
            }

            return null;
        }
    }
808047
public function request($url)
    {
        $curlOpts = array_replace($this->curlOpts, [CURLOPT_URL => $url]);

        $ch = curl_init();
        foreach ($curlOpts as $opt => $optVal) {
            curl_setopt($ch, $opt, $optVal);
        }

        $resp = curl_exec($ch);
        $info = (object) curl_getinfo($ch);
        curl_close($ch);

        //Check response
        $httpCode = (string) $info->http_code;
        if ($httpCode{0} != '2') {
            $msg = sprintf('HTTP Request Failed (code %s): %s', $info->http_code, $resp);
            throw new HttpException($resp, $msg, $httpCode);
        } elseif (strlen(trim($resp)) == 0) {
            throw new HttpException($resp, 'HTTP Response Empty');
        }

        return $resp;
    }
549716
public function post(string $url, $params = null): HttpResponse
    {
        return $this->send('POST', $url, [
            $this->bodyFormat => $params,
        ]);
    }
1036074
public function parse($url)
    {
        $this->_fixUrlForParsing($url);

        if (empty($url->path) && !isset($url->query['option'])) {
            $url->path = (get_viewer()->guest()) ? 'pages' : 'dashboard';
        }

        $segments = explode('/', trim($url->path, '/'));
        $segments = array_filter($segments);

        if (!empty($segments)) {
            $component = array_shift($segments);
            $url->query = array_merge(array('option' => 'com_'.$component), $url->query);
            $component = str_replace('com_', '', $url->query['option']);
            $query = $this->getComponentRouter($component)->parse($segments);
            $url->query = array_merge($url->query, array('option' => 'com_'.$component), $query);
        }

        return $url;
    }
1308936
protected function prepareUrl($url)
    {
        if (null === $url) {
            $url = Environment::get('requestUri');
        } elseif (is_numeric($url)) {
            if (null === ($jumpTo = $this->framework->getAdapter(PageModel::class)->findByPk($url))) {
                throw new \InvalidArgumentException('Given page id does not exist.');
            }

            $url = $this->framework->getAdapter(Controller::class)->generateFrontendUrl($jumpTo->row());

            list(, $queryString) = explode('?', Environment::get('request'), 2);

            if ('' != $queryString) {
                $url .= '?'.$queryString;
            }
        }

        $url = ampersand($url, false);

        return $url;
    }
1283892
protected function exec($url)
    {
        $client = $this->getRequest();
        try{
            $response = $client->request('POST',$this->buildRequestUrl(),[
                'json' => [
                    'longUrl' => $url
                ]
            ]);
        } catch (\GuzzleHttp\Exception\ClientException $e){
            $response = $e->getResponse();
        }
        return $this->handleResponse($response->getBody());
    }
819934
public function delete(string $url, array $params = []): HttpResponse
    {
        return $this->send('DELETE', $url, [
            $this->bodyFormat => $params,
        ]);
    }