Method to wrap fetching to service:
- get() if uri is not null
- getAll() if uri is null

@param null $uri
@return mixed
@throws common_exception_InvalidArgumentType
@throws common_exception_PreConditionFailure
437383
protected function get($uri=null)
    {
        if (!is_null($uri)) {
            if (!($this->getCrudService()->isInScope($uri))) {
                throw new common_exception_PreConditionFailure("The URI must be a valid resource under the root Class");
            }
            return $this->getCrudService()->get($uri);
        } else {
            return $this->getCrudService()->getAll();
        }
    }
1131691
protected function getClient($uri)
	{
		// TODO For some reason the Alfresco client goes into an infinite loop when returning
		// the children of an item (when you call getChildren on the company home)
		// it returns itself as its own child, unless you recreate the client. It seems
		// to maintain all the request body... or something weird.
		if (!$this->httpClient || !$this->maintainSession) {
			$this->httpClient = new Zend_Http_Client($uri, array(
	    			'maxredirects' => 0,
	    			'timeout'      => 10
				)
			);

			if ($this->useCookies) {
				$this->httpClient->setCookieJar();
			}
		} else {
			$this->httpClient->setUri($uri);
		}

		// clear it out
		if ($this->maintainSession) {
			$this->httpClient->resetParameters();
		}

		if ($this->authInfo) {
			$this->httpClient->setAuth($this->authInfo['user'], $this->authInfo['pass']);
		}

		return $this->httpClient;
	}
974873
protected function resolveCurrentUri($exception = NULL)
    {
        try {
            $activeRoutes = $this->getActiveRoutes($exception);
            foreach ($activeRoutes as $controller => $routes) {
                foreach ($routes as $action => $route) {
                    $result = $this->callController($controller, $action, $route);
                    if ($result === TRUE) {
                        return NULL;
                    } else if (!is_null($result)) {
                        return $this->render($result);
                    }
                }
            }
            $this->throw404($exception);
        } catch (\Exception $exception) {
            $this->preventExceptionLoop($exception);
            $this->exceptions[] = $exception;
            return $this->resolveCurrentUri($exception);
        }
    }
1113294
public function getOrLoad(string $uri): Promise
    {
        return isset($this->documents[$uri]) ? Promise\resolve($this->documents[$uri]) : $this->load($uri);
    }
666785
public function get(string $uri): Description
    {
        if (!$uri) {
            throw new \InvalidArgumentException("No document URI provided");
        }
        if ($this->basePath) {
            $uri = "$this->basePath/$uri";
        }
        if (!isset($this->specifications[$uri])) {
            $this->specifications[$uri] = $this->load($uri);
        }

        return $this->specifications[$uri];
    }
901887
public static function create($uri)
    {
        if (($parse = parse_url($uri)) === false) {
            throw new \InvalidArgumentException('Unable to parse URI');
        }

        return new Uri(
            isset($parse[ 'scheme' ])
                ? $parse[ 'scheme' ]
                : '',
            isset($parse[ 'host' ])
                ? $parse[ 'host' ]
                : '',
            isset($parse[ 'path' ])
                ? $parse[ 'path' ]
                : '',
            isset($parse[ 'port' ])
                ? $parse[ 'port' ]
                : '',
            isset($parse[ 'query' ])
                ? $parse[ 'query' ]
                : '',
            isset($parse[ 'fragment' ])
                ? $parse[ 'fragment' ]
                : '',
            isset($parse[ 'user' ])
                ? $parse[ 'user' ]
                : '',
            isset($parse[ 'pass' ])
                ? $parse[ 'pass' ]
                : ''
        );
    }
763681
public function retrieve($uri)
    {
        $ch = curl_init();

        curl_setopt($ch, CURLOPT_URL, $uri);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));

        $response = curl_exec($ch);
        if (false === $response) {
            throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
        }

        $this->fetchMessageBody($response);
        $this->fetchContentType($response);

        curl_close($ch);

        return $this->messageBody;
    }
1331911
public function get($id)
    {
        if (!$this->has($id)) {
            // a class name.
            if (strpos($id, '\\') && class_exists($id)) {
                /** @noinspection ExceptionsAnnotatingAndHandlingInspection */
                $this->set($id, $id);
            } else {
                throw new \InvalidArgumentException("The service '$id' was not found, has not been registered!");
            }
        }

        return $this->getInstance($id);
    }
62890
protected function getURI(): string
    {
        if (empty($this->baseUrl) || empty($this->uri)) {
            throw new Exception('Url or end point can not be null');
        }

        return $this->baseUrl . $this->uri;
    }
877949
public function get($uri, $parameters = array())
    {
        return $this->request(self::METHOD_GET, $this->getUrl($uri), $parameters);
    }
1364630
public function parseUri()
    {
        $uri = (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null);

        if(isset($uri))
        {
            $uri = '/' . ltrim(trim($uri), '/');
            $uri = filter_var($uri, FILTER_SANITIZE_URL);

            return $uri;
        }
        else
        {
            throw new Exception("Error parsing URI please check your URI.", 1);
        }
    }
295852
protected function _parseUri($uri)
    {
        $parts = parse_url($uri);

        if (false === $parts) {
            throw new \InvalidArgumentException(
                'The source URI string appears to be malformed'
            );
        }

        $this->_scheme    = isset($parts['scheme'])   ? $this->_filterScheme($parts['scheme']) : '';
        $this->_userInfo  = isset($parts['user'])     ? $parts['user']     : '';
        $this->_host      = isset($parts['host'])     ? $parts['host']     : '';
        $this->_port      = isset($parts['port'])     ? $parts['port']     : null;
        $this->_path      = isset($parts['path'])     ? $this->_filterPath($parts['path']) : '';
        $this->_query     = isset($parts['query'])    ? $this->_filterQuery($parts['query']) : '';
        $this->_fragment  = isset($parts['fragment']) ? $this->_filterFragment($parts['fragment']) : '';

        if (isset($parts['pass'])) {
            $this->_userInfo .= ':' . $parts['pass'];
        }
    }
69163
public static function get($uri)
	{
		return self::where('uri','=',$uri)
			->where('status','=',Page::APPROVED)
			->where('published_date','<=',\Carbon\Carbon::now())
			->first();
	}
314671
private function getResourceParam($uri)
    {
        $resource = $this->injector->getInstance(ResourceInterface::class);
        $resourceResult = $resource->get->uri($uri)->eager->request();
        $fragment = parse_url($uri, PHP_URL_FRAGMENT);

        return $resourceResult[$fragment];
    }
497344
protected function openStream(string $uri)
    {
        $scheme = parse_url($uri, PHP_URL_SCHEME);

        if (!isset($scheme) || $scheme === '') {
            throw new \InvalidArgumentException("Invalid URI '$uri'; scheme missing");
        }

        $reporting = error_reporting(error_reporting() & ~(E_WARNING | E_NOTICE));
        try {
            $stream = fopen($uri, 'w'); // Just in case stream wrapper throws an exception
        } finally {
            error_reporting($reporting);
        }

        if (!is_resource($stream)) {
            ['message' => $message] = error_get_last() ?? ['message' => "Failed to open '$uri'"];
            throw new \RuntimeException($message);
        }

        return $stream;
    }
684394
public function createAbsoluteUrl($uri)
    {
        if (!isset($uri)) {
            return null;
        }

        $uri = strval($uri);
        if ($this->isRelativeUri($uri)) {
            $parts = parse_url($uri);
            $path  = isset($parts['path']) ? $parts['path'] : '';
            $query = isset($parts['query']) ? $parts['query'] : '';
            $hash  = isset($parts['fragment']) ? $parts['fragment'] : '';

            return $this->baseUrl()->withPath($path)->withQuery($query)->withFragment($hash);
        }

        return $uri;
    }
1342932
public function uri($uri = null)
    {
        $page = $this->findPageByUri($uri);

        abort_if(!$page, '404');

        if ($page->private && !Auth::check()) {
            return redirect()->guest(route(app()->getLocale().'::login'));
        }

        if ($page->redirect && $page->subpages->count() > 0) {
            $childUri = $page->subpages->first()->uri();

            return redirect($childUri);
        }

        // get submenu
        $children = $this->repository->getSubMenu($page->uri);

        $templateDir = 'pages::'.config('typicms.template_dir', 'public').'.';
        $template = $page->template ?: 'default';

        if (!view()->exists($templateDir.$template)) {
            info('Template '.$template.' not found, switching to default template.');
            $template = 'default';
        }

        return response()->view($templateDir.$template, compact('children', 'page'));
    }