Returns $pathinfo with base url of current page
If $site is provided, the url will be pointing on the associate domain.

@param string             $pathinfo
@param string             $defaultExt
@param \BackBee\Site\Site $site

@return string
542516
public function getUri($pathinfo = null, $defaultExt = null, Site $site = null, $url_type = null)
    {
        return $this->getApplication()->getRouting()->getUri($pathinfo, $defaultExt, $site, $url_type);
    }
200098
public static function getCurrentUrl(): string
    {
        $siteUrl = self::getSiteUrl();
        
        $request = self::getServerVariable('REQUEST_URI', self::getServerVariable('PHP_SELF', ''));
        $query = self::getQueryString();
        
        $indexPhpFound = strpos($request, INDEX_FILE);
        if (!USE_INDEX_FILE && ($indexPhpFound === 0 || $indexPhpFound === 1)) {
            // remove index.php
            $request = str_replace(INDEX_FILE, '', $request);
        }
        
        $currentUrl = $siteUrl . $request;
        if (!empty($query) && strpos($request, $query) === false) {
            $currentUrl .= '?' . $query;
        }
        
        return preg_replace("#([^:])//+#", "$1/", $currentUrl);
    }
1214140
protected function generateCoreSelectorMenu(Site $site, string $uriToRedirectTo = null)
    {
        if (!$this->view instanceof BackendTemplateView) {
            throw new InvalidViewObjectNameException(vsprintf(
                'The controller "%s" must use BackendTemplateView to be able to generate menu for backends docheader. \
                Please set `protected $defaultViewObjectName = BackendTemplateView::class;` field in your controller.',
                [static::class]), 1493804179);
        }
        $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());

        $this->coreSelectorMenu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
        $this->coreSelectorMenu->setIdentifier('component_core_selector_menu');

        if (!isset($uriToRedirectTo)) {
            $uriToRedirectTo = $this->uriBuilder->reset()->uriFor();
        }

        $this->initializeSelectedSolrCoreConnection();
        $cores = $this->solrConnectionManager->getConnectionsBySite($site);
        foreach ($cores as $core) {
            $coreAdmin = $core->getAdminService();
            $menuItem = $this->coreSelectorMenu->makeMenuItem();
            $menuItem->setTitle($coreAdmin->getCorePath());
            $uri = $this->uriBuilder->reset()->uriFor('switchCore',
                [
                    'corePath' => $coreAdmin->getCorePath(),
                    'uriToRedirectTo' => $uriToRedirectTo
                ]
            );
            $menuItem->setHref($uri);

            if ($coreAdmin->getCorePath() == $this->selectedSolrCoreConnection->getAdminService()->getCorePath()) {
                $menuItem->setActive(true);
            }
            $this->coreSelectorMenu->addMenuItem($menuItem);
        }

        $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($this->coreSelectorMenu);
    }
156177
public function getPathInfo()
	{
		$path = trim($this->uri->getPath(false), '/');
		
		if($this->pathBase == '')
		{
			return $path;
		}
		
		if($path == $this->pathBase)
		{
			return '';
		}
		
		return preg_replace("'^" . preg_quote($this->pathBase, "'") . "/'i", '', $path);
	}
125775
function getExpressRoutePrefix(site) {
  let prefix = site.host;

  if (site.path.length > 1) {
    prefix += site.path;
  }

  return prefix;
}
1081485
public function getPrimaryRedirectUrl(Site $site)
    {
        $currentDomain = $site->getDomain()->getDomainName();

        $ipValidator = new Ip();
        $isIp = $ipValidator->isValid($currentDomain);

        if ($isIp) {
            return null;
        }

        $primaryDomain = $site->getDomain()->getPrimary();

        if (empty($primaryDomain)) {
            return null;
        }

        if ($primaryDomain->getDomainName() == $currentDomain) {
            return null;
        }

        return $primaryDomain->getDomainName();
    }
839853
public function getCurrentDomain($default = null)
    {
        $currentDomain = PhpServer::getRequestDomain();

        //Use the default site if the requested domain name is an IP address
        $ipValidator = new Ip();
        if ($ipValidator->isValid($currentDomain)) {
            $currentDomain = $default;
        }

        return $currentDomain;
    }
1113230
public function match($pathinfo)
    {
        $return = null;

        // Default (homepage) - index.html
        if (
            ('/' === $pathinfo) &&
            ($index_template = $this->resolver->resolveIndexTemplate())
        ) {
            $return = array(
                '_controller' => $this->controller,
                '_route' => $index_template->getRenderName(),
                'template' => $index_template,
            );
        }

        // 404 not found - 404.html

        if (!$return && ($nf_template = $this->resolver->resolveNotFoundTemplate())) {
            $return = array(
                '_controller' => $this->controller,
                '_route' => $nf_template->getRenderName(),
                'template' => $nf_template,
            );
        }

        // 404 not found - last resort
        if (!$return) {
            $return = array(
                '_controller' => $this->errorController,
                '_route' => '404',
            );
        }

        return($return);
    }
856727
public function siteHref(string $site, string $controller = null, string $action = null, array $params = null, string $lang = null): string
    {
        if ($controller !== null && strpos($controller, '/') !== false) {
            throw new \InvalidArgumentException('Slash is not allowed in controller name');
        }

        if ($action !== null && strpos($action, '/') !== false) {
            throw new \InvalidArgumentException('Slash is not allowed in action name');
        }

        if ($controller === null) {
            $controller = '';
        }

        if ($site !== '') {
            // we're building link to another server
            $otherSite = Application::getConfig('sites')->get($site);
            if ($otherSite !== null) {
                $url = $otherSite;
            } else {
                Log::warning('Missing sites definition key \'' . $site . '\'; please define it in your sites.php config');
                $url = Application::getDomainWithSchema();
            }
        } else {
            $url = Application::getDomainWithSchema();
        }

        $url .= '/' . $controller;

        if ($action !== null) {
            $url .= '/' . $action;
        }

        if ($params !== null && count($params) > 0) {
            $q = [];
            foreach ($params as $key => $value) {
                if (is_numeric($key)) {
                    $url .= '/' . $value;
                } else {
                    $q[$key] = $value;
                }
            }

            if (sizeof($q) > 0) {
                $url .= '?';
                foreach ($q as $key => $value) {
                    $url .= "{$key}={$value}&";
                }
                $url = substr($url, 0, -1);
            }
        }

        return $url;
    }
126019
static function Page404(Site $site)
    {
        $sql = Access::SqlBuilder();
        $tblPage = Page::Schema()->Table();
        $where = $sql->Equals($tblPage->Field('Type'), $sql->Value((string) PageType::NotFound()))
                ->And_($sql->Equals($tblPage->Field('Site'), $sql->Value($site->GetID())));

        return Page::Schema()->First($where);
    }
877197
public function getExt()
    {
        if (is_null($this->ext) && $this->originFile) {
            $file = basename($this->originFile);
            // Use substr instead of pathinfo, because pathinfo may return error value in unicode
            if (false !== $pos = strrpos($file, '.')) {
                $this->ext = strtolower(substr($file, $pos + 1));
            } else {
                $this->ext = '';
            }
        }
        return $this->ext;
    }
50626
protected function prepareDefaultValues(
        Site $site,
        array $defaultSiteSettings,
        string $createdByUserId,
        string $createdReason
    ) {
        $defaults = $this->getDefaultSiteValues(
            $defaultSiteSettings,
            $createdByUserId,
            $createdReason
        );

        foreach ($defaults as $key => $value) {
            $getMethod = 'get' . ucfirst($key);
            $setMethod = 'set' . ucfirst($key);

            $currentValue = $site->$getMethod();

            if (empty($currentValue)) {
                $site->$setMethod($value);
            }
        }

        return $site;
    }
1185243
protected function siteUrl($path, $includeIndex = false)
    {
        $path = trim($path, '/');
        return $this->data['baseUrl'].$path;
    }
232280
static function findPathToSiteAccess( $siteAccess )
    {
        $ini = eZINI::instance();
        $siteAccessList = $ini->variable( 'SiteAccessSettings', 'AvailableSiteAccessList' );
        if ( !in_array( $siteAccess, $siteAccessList )  )
            return false;

        $currentPath = 'settings/siteaccess/' . $siteAccess;
        if ( file_exists( $currentPath ) )
            return $currentPath;

        $activeExtensions = eZExtension::activeExtensions();
        $baseDir = eZExtension::baseDirectory();
        foreach ( $activeExtensions as $extension )
        {
            $currentPath = $baseDir . '/' . $extension . '/settings/siteaccess/' . $siteAccess;
            if ( file_exists( $currentPath ) )
                return $currentPath;
        }

        return 'settings/siteaccess/' . $siteAccess;
    }
1108731
public function url($default=null) {
		if($this->isIn($this->webDir))
			$src = $this->relativeToWebDir();
		else
			$src = $default;

		if($this->url && $src)
			return $this->url->to($src);
		else
			return $src;
	}
1252333
public function removeIdxSiteContent(Site $site, AbstractClassContent $content)
    {
        $query = 'DELETE FROM idx_site_content WHERE site_uid = :site AND (content_uid IN '.
                '(SELECT content_uid FROM content_has_subcontent WHERE parent_uid = :content)'.
                'OR content_uid = :content)';

        $params = array(
            'site' => $site->getUid(),
            'content' => $content->getUid(),
        );

        return $this->executeUpdate($query, $params);
    }
359237
function pathWithNames( $regenerateCurrent = false )
    {
        // Only set name if current node is not the content root
        $ini = eZINI::instance( 'content.ini' );
        $contentRootID = $ini->variable( 'NodeSettings', 'RootNode' );
        if ( $this->attribute( 'node_id' ) != $contentRootID )
        {
            $pathArray = $this->pathArray();
            // Get rid of node with ID 1 (a special node)
            array_shift( $pathArray );
            if ( $regenerateCurrent )
            {
                // Get rid of current node, path element for this will be calculated
                array_pop( $pathArray );
            }
            if ( count( $pathArray ) == 0 )
            {
                $path = '';
            }
            else
            {
                $path = eZURLAliasML::fetchPathByActionList( "eznode", $pathArray, $this->CurrentLanguage );
            }

            // Fallback in case fetchPathByActionList() fails,
            // then we ask for the path from the parent and generate the current
            // entry ourselves.
            if ( $path === null )
            {
                if ( $this->attribute( 'depth' ) == 0 ) // Top node should just return empty string
                {
                    return '';
                }

                eZDebug::writeError( __METHOD__ . "() failed to fetch path of node " . $this->attribute( 'node_id' ) . ", falling back to generated url entries. Run updateniceurls.php to fix the problem." );

                // Return a perma-link when the path lookup failed, this link will always work
                $path = 'content/view/full/' . $this->attribute( 'node_id' );
                return $path;
            }

            if ( $regenerateCurrent )
            {
                $nodeName = $this->attribute( 'name' );
                $nodeName = eZURLAliasML::convertToAlias( $nodeName, 'node_' . $this->attribute( 'node_id' ) );

                if ( $path != '' )
                {
                    $path .= '/' . $nodeName ;
                }
                else
                {
                    $path  = $nodeName ;
                }
            }
        }
        else
        {
            $path = '';
        }

        if ( $regenerateCurrent )
        {
            $path = $this->checkPath( $path );
        }
        return $path;
    }