Stores custom URL alias data for $path to the backup table.

@param int $locationId
@param string $path
@param string $languageCode
@param bool $alwaysAvailable
@param bool $forwarding
1270
protected function storeCustomAliasPath(
        $locationId,
        $path,
        $languageCode,
        $alwaysAvailable,
        $forwarding
    ) {
        $queryBuilder = $this->connection->createQueryBuilder();

        $queryBuilder->insert(static::CUSTOM_ALIAS_BACKUP_TABLE);
        $queryBuilder->values(
            [
                'id' => '?',
                'location_id' => '?',
                'path' => '?',
                'language_code' => '?',
                'always_available' => '?',
                'forwarding' => '?',
            ]
        );
        $queryBuilder->setParameter(0, 0);
        $queryBuilder->setParameter(1, $locationId);
        $queryBuilder->setParameter(2, $path);
        $queryBuilder->setParameter(3, $languageCode);
        $queryBuilder->setParameter(4, (int)$alwaysAvailable);
        $queryBuilder->setParameter(5, (int)$forwarding);

        $queryBuilder->execute();
    }
1266692
private function getLanguage(array $languageCodes, $mainLanguageCode, $alwaysAvailable)
    {
        $languageCodesSet = array_flip($languageCodes);

        foreach ($this->settings->prioritizedLanguages as $languageCode) {
            if (isset($languageCodesSet[$languageCode])) {
                return $languageCode;
            }
        }

        if ($this->settings->useAlwaysAvailable && $alwaysAvailable) {
            return $mainLanguageCode;
        }

        return null;
    }
697462
protected function saveCurrentAccessTokenToFile(string $tokenFilePath)
    {
        $this->logger->info('Saving the access token to the `'.$tokenFilePath.'` file');

        $token = $this->client->getAccessToken();
        if ($token === null) {
            throw new \LogicException('Can\'t save the token because the current Google client doesn\'t have an access token');
        }

        try {
            $this->saveCredentialJSON($tokenFilePath, $token);
        } catch (\RuntimeException $exception) {
            throw new \RuntimeException('Failed to save the access token: '.$exception->getMessage());
        }
    }
537285
protected function findOrCreateRoute($path, $locale, CustomUrlBehavior $document, $route)
    {
        try {
            /** @var RouteDocument $routeDocument */
            $routeDocument = $this->documentManager->find($path, $locale);
        } catch (DocumentNotFoundException $ex) {
            return $this->documentManager->create('custom_url_route');
        }

        if (!$routeDocument instanceof RouteDocument
            || $routeDocument->getTargetDocument()->getUuid() !== $document->getUuid()
        ) {
            throw new ResourceLocatorAlreadyExistsException($route, $document->getTitle());
        }

        return $routeDocument;
    }
1356965
public function toRoute($name, array $args = [], $code = 307)
    {
        $to = $this->getRoute($name, $args);

        header("location: {$to}", true, $code);
        exit;
    }
212142
private function resolveContentCreateData(
        ContentType $contentType,
        Location $location,
        string $languageCode
    ): ContentCreateData {
        $contentCreateMapper = new ContentCreateMapper();

        return $contentCreateMapper->mapToFormData(
            $contentType,
            [
                'mainLanguageCode' => $languageCode,
                'parentLocation' => $this->locationService->newLocationCreateStruct($location->id, $contentType),
            ]
        );
    }
1018194
public function locationCopied($locationId, $newLocationId, $newParentId)
    {
        $newParentAliasId = $this->getRealAliasId($newLocationId);
        $oldParentAliasId = $this->getRealAliasId($locationId);

        $actionMap = $this->getCopiedLocationsMap($locationId, $newLocationId);

        $this->copySubtree(
            $actionMap,
            $oldParentAliasId,
            $newParentAliasId
        );
    }
46322
public function findTranslatedRouteByPath($path, $locale)
    {
        // check if this url is a translated url
        foreach ($this->translatedRoutes as $route) {
            if ($this->translate($route, $locale) == rawurldecode($path))
                return $route;
        }

        return false;
    }
313381
private function loadLocationEntriesMatchingMultipleLanguages($locationId, array $languageIds)
    {
        // note: alwaysAvailable for this use case is not relevant
        $languageMask = $this->languageMaskGenerator->generateLanguageMaskFromLanguageIds(
            $languageIds,
            false
        );

        $connection = $this->dbHandler->getConnection();
        /** @var \Doctrine\DBAL\Connection $connection */
        $query = $connection->createQueryBuilder();
        $query
            ->select('id', 'lang_mask', 'parent', 'text_md5')
            ->from($this->table)
            ->where('action = :action')
            // fetch rows matching any of the given Languages
            ->andWhere('lang_mask & :languageMask <> 0')
            ->setParameter(':action', 'eznode:' . $locationId)
            ->setParameter(':languageMask', $languageMask)
        ;

        $statement = $query->execute();
        $rows = $statement->fetchAll(\PDO::FETCH_ASSOC);

        return $rows ?: [];
    }
1330090
public function addTranslationFile($path, $language)
    {
        if (!file_exists($path)) {
            throw new \InvalidArgumentException('Translation file "'.$path.'" not found');
        }

        $language = (string) $language;
        if ($language === '') {
            throw new \InvalidArgumentException('$language cannot be empty');
        }

        $this->files[$language][] = $path;
    }
253001
public function language($code, $path = '', $options = array())
    {
        $segments = $this->getSegments(true, $path);
        $langcode = $this->request->getLangcode();

        if (isset($segments[0]) && $segments[0] === $langcode) {
            unset($segments[0]);
        }

        array_unshift($segments, $code);

        $url = $this->request->base(true) . trim(implode('/', $segments), '/');
        $url = empty($options) ? $url : "$url?" . http_build_query($options);

        return filter_var($url, FILTER_SANITIZE_URL);
    }
1248543
protected function isPathLoadable(array $pathData, array $languageCodes)
    {
        if ($this->settings['showAllTranslations']) {
            return true;
        }

        foreach ($pathData as $level => $levelPathData) {
            if ($levelPathData['always-available']) {
                continue;
            }

            if (in_array($languageCodes[$level], $this->settings['prioritizedLanguageList'])) {
                continue;
            }

            return false;
        }

        return true;
    }
133666
public function getStoragePathForField($fieldId, $versionNo, $languageCode)
    {
        return sprintf(
            '%s/%s-%s-%s',
            $this->getDirectoryStructure($fieldId),
            $fieldId,
            $versionNo,
            $languageCode
        );
    }
165662
private function getLocalXliffFile(TranslationResource $resource, $languageCode)
    {
        $domain    = substr($resource->getSlug(), strlen($this->prefix));
        $localFile = $this->txlang . DIRECTORY_SEPARATOR .
            substr($languageCode, 0, 2) . DIRECTORY_SEPARATOR .
            $domain . '.xlf';

        $local = new XliffFile($localFile);
        if (!file_exists($localFile)) {
            // Set base values.
            $local->setDataType('php');
            $local->setOriginal($domain);
            $local->setSrcLang($this->baselanguage);
            $local->setTgtLang(substr($languageCode, 0, 2));
        }

        return $local;
    }
236357
public function addAlias($location, $path) {
    $this->setVar('aliases', 
      $this->getVar('aliases').
      sprintf("\n  Alias %s %s", $location , $this->replaceHelpers($path))
    );
    return $this;
  }
1103413
public void sendRedirect(String location, boolean permanent) throws IOException {

        // Ignore any redirects after the first one
        if (isSuspended() && (!location.equals(m_bufferRedirect))) {
            return;
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug(Messages.get().getBundle().key(Messages.LOG_FLEXRESPONSE_SENDREDIRECT_1, location));
        }
        if (m_cachingRequired && !m_includeMode) {
            m_bufferRedirect = location;
            m_redirectPermanent = permanent;
        }

        if (!m_cachingRequired) {
            // If caching is required a cached entry will be constructed first and redirect will
            // be called after this is completed and stored in the cache
            if (LOG.isDebugEnabled()) {
                LOG.debug(
                    Messages.get().getBundle().key(Messages.LOG_FLEXRESPONSE_TOPRESPONSE_SENDREDIRECT_1, location));
            }
            if (LOG.isWarnEnabled()) {
                if (m_controller.getResponseStackSize() > 2) {
                    // sendRedirect in a stacked response scenario, this may cause issues in some app servers
                    LOG.warn(
                        Messages.get().getBundle().key(
                            Messages.LOG_FLEXRESPONSE_REDIRECTWARNING_3,
                            m_controller.getCmsResource().getRootPath(),
                            m_controller.getCurrentRequest().getElementUri(),
                            location));
                }
            }
            try {
                // Checking for possible illegal characters (for example, XSS exploits) before sending the redirect
                // The constructor is key here. That method will throw an URISyntaxException if the URL
                // format is not according to standards (e.g. contains illegal characters, like spaces, < or >, etc).
                @SuppressWarnings("unused")
                URI validURI = new URI(location);
            } catch (URISyntaxException e) {
                // Deliberately NOT passing the original exception, since the URISyntaxException contains the full path,
                // which may include the XSS attempt
                LOG.error(Messages.get().getBundle().key(Messages.ERR_FLEXRESPONSE_URI_SYNTAX_EXCEPTION_0), e);
                throw new IllegalArgumentException("Illegal or malformed characters found in path");
            }

            // use top response for redirect
            HttpServletResponse topRes = m_controller.getTopResponse();
            // add all headers found to make sure cookies can be set before redirect
            processHeaders(getHeaders(), topRes);
            if (permanent) {
                topRes.setHeader(CmsRequestUtil.HEADER_LOCATION, location);
                topRes.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
            } else {
                topRes.sendRedirect(location);
            }
        }
        m_controller.suspendFlexResponse();
    }
1342955
function nativeCopy($path, $newPath)
    {
        if (!$this->createDir(Util::dirname($newPath), new Config())) {
            return false;
        }

        $location    = $this->applyPathPrefix($this->encodePath($path));
        $newLocation = $this->applyPathPrefix($this->encodePath($newPath));

        try {
            $destination = $this->client->getAbsoluteUrl($newLocation);
            $response    = $this->client->request('COPY', '/' . ltrim($location, '/'), null, [
                'Destination' => $destination,
            ]);

            if ($response['statusCode'] >= 200 && $response['statusCode'] < 300) {
                return true;
            }
        } catch (NotFound $e) {
            // Would have returned false here, but would be redundant
        }

        return false;
    }