Create markup for URLs in current location data.
@param array $location
@param array $result the result containing $location
@return \DOMElement
967278
protected function electronicURLs($location, $result)
    {
        $electronicURLs = $this->cleanURLList($location, $result);
        $URLsContainer = null;

        if ($electronicURLs && count($electronicURLs) != 0) {
            $URLsContainer = $this->doc->createElement('span');

            foreach ($electronicURLs as $URLInfo) {
                $linkTexts = [];
                $linkURL = $URLInfo['values'][0];

                if ($URLInfo['attrs']['name']) {
                    $linkTexts[] = $URLInfo['attrs']['name'];
                    if ($URLInfo['attrs']['note']) {
                        $linkTexts[] = $URLInfo['attrs']['note'];
                    }
                } elseif ($URLInfo['attrs']['note']) {
                    $linkTexts[] = $URLInfo['attrs']['note'];
                } elseif ($URLInfo['attrs']['fulltextfile']) {
                    $linkTexts[] = 'Document';
                } else {
                    $linkTexts[] = 'Link';
                }

                $localisedLinkTexts = [];
                foreach ($linkTexts as $linkText) {
                    $localisedLinkText = LocalizationUtility::translate('link-description-' . $linkText, 'Pazpar2');
                    if (!$localisedLinkText) {
                        $localisedLinkText = $linkText;
                    }
                    $localisedLinkTexts[] = $localisedLinkText;
                }
                $linkText = '[' . implode(', ', $localisedLinkTexts) . ']';

                if ($URLsContainer->hasChildNodes()) {
                    $URLsContainer->appendChild($this->doc->createTextNode(', '));
                }

                $link = $this->doc->createElement('a');
                $URLsContainer->appendChild($link);
                $link->setAttribute('class', 'pz2-electronic-url');
                $link->setAttribute('href', $linkURL);
                $this->turnIntoNewWindowLink($link);
                $link->appendChild($this->doc->createTextNode($linkText));
            }
            $URLsContainer->appendChild($this->doc->createTextNode('; '));
        }

        return $URLsContainer;
    }
505819
public function redirectTo($location) {
        $app = $GLOBALS['app'];
        $host = $_SERVER['HTTP_HOST'];
        if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
            $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
        }
        $protocol = isset($_SERVER['HTTPS'])?'https://':'http://'; 
        $redirectLocation = $protocol.$host.'/'.$app->getConfiguration()->getApplicationContext().'/'.$location;
        if ($app->getSubject()->isAuthenticated()) {
            $separator = '?';
            if(strpos($redirectLocation, '?'))
                $separator = '&';
            $redirectLocation .= $separator."rand_token=".urlencode($app->getSessionManager()->getActiveSession()->getAttribute('nonce'));
        }
        if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && 
            strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
                $this->addHeader("Content-type: application/json");
                $response = array();
                $response['redirect'] = $redirectLocation;
                echo json_encode($response);
                exit;
        } else {
            $this->addHeader('Location: '.$redirectLocation);
        }
    }
1363429
public function renderOnSuccess($result, SilexKernel $silexKernel)
    {
        if (!is_array($result)) {
            $result = ['result' => $result];
        }
        
        return new JsonResponse($result);
    }
760722
public function addTag($location, $lastModified = null, $changeFrequency = null, $priority = null)
    {
        $tag = $location instanceof Tag ? $location : new Tag($location, $lastModified, $changeFrequency, $priority);

        $this->tags[] = $tag;

        return $tag;
    }
1345529
public static function formatResult($result, $decorate = true)
    {
        $name = isset(self::$stateNames[$result]) ? self::$stateNames[$result] : $result;

        return $decorate && $result === Activity::RESULT_FAILURE
            ? '<error>' . $name . '</error>'
            : $name;
    }
941449
public function viewParentExtraInfoAction(Location $location)
    {
        $repository = $this->getRepository();
        $parentLocation = $repository->getLocationService()->loadLocation($location->parentLocationId);

        // TODO once the keyword service is available replace part this subrequest by a full symfony one

        return $this->render(
            'eZDemoBundle:parts/blog:extra_info.html.twig',
            array('location' => $parentLocation)
        );
    }
1212837
public function doGenerate($location, array $parameters)
    {
        $urlAliasService = $this->repository->getURLAliasService();

        $siteaccess = null;
        if (isset($parameters['siteaccess'])) {
            $siteaccess = $parameters['siteaccess'];
            unset($parameters['siteaccess']);
        }

        if ($siteaccess) {
            // We generate for a different SiteAccess, so potentially in a different language.
            $languages = $this->configResolver->getParameter('languages', null, $siteaccess);
            $urlAliases = $urlAliasService->listLocationAliases($location, false, null, null, $languages);
            // Use the target SiteAccess root location
            $rootLocationId = $this->configResolver->getParameter('content.tree_root.location_id', null, $siteaccess);
        } else {
            $languages = null;
            $urlAliases = $urlAliasService->listLocationAliases($location, false);
            $rootLocationId = $this->rootLocationId;
        }

        $queryString = '';
        unset($parameters['language'], $parameters['contentId']);
        if (!empty($parameters)) {
            $queryString = '?' . http_build_query($parameters, '', '&');
        }

        if (!empty($urlAliases)) {
            $path = $urlAliases[0]->path;
            // Remove rootLocation's prefix if needed.
            if ($rootLocationId !== null) {
                $pathPrefix = $this->getPathPrefixByRootLocationId($rootLocationId, $languages, $siteaccess);
                // "/" cannot be considered as a path prefix since it's root, so we ignore it.
                if ($pathPrefix !== '/' && ($path === $pathPrefix || mb_stripos($path, $pathPrefix . '/') === 0)) {
                    $path = mb_substr($path, mb_strlen($pathPrefix));
                } elseif ($pathPrefix !== '/' && !$this->isUriPrefixExcluded($path) && $this->logger !== null) {
                    // Location path is outside configured content tree and doesn't have an excluded prefix.
                    // This is most likely an error (from content edition or link generation logic).
                    $this->logger->warning("Generating a link to a location outside root content tree: '$path' is outside tree starting to location #$rootLocationId");
                }
            }
        } else {
            $path = $this->defaultRouter->generate(
                self::INTERNAL_CONTENT_VIEW_ROUTE,
                array('contentId' => $location->contentId, 'locationId' => $location->id)
            );
        }

        $path = $path ?: '/';

        // replace potentially unsafe characters with url-encoded counterpart
        return strtr($path . $queryString, $this->unsafeCharMap);
    }
1130460
public function setResult($name = null, $result = null)
    {
        if (null === $result) {
            $result = $name;
            array_push($this->results, $result);

            return $this;
        }

        $this->results[(string) $name] = $result;

        return $this;
    }
443454
protected function replaceTemplate($url, $text, $result = TRUE) {
		$template = ($result ? $this->get('active') : $this->get('common'));
		$html = str_replace('{url}', $url, $template);
		return str_replace('{text}', $text, $html);
	}
823674
public function createLocation(string $location, string $match = null) : Location
    {
        return new Location(new Param($location), is_null($match) ? null : new Param($match));
    }
1230287
public static function createFromLocation(Location $location): self
    {
        $message = new self();
        $message->setId($location->getId());
        $message->setTel($location->getTel());
        $message->setFax($location->getFax());
        $message->setMail($location->getMail());
        $message->setAddress($location->getAddress());
        $message->setPostalCode($location->getPostalCode());
        $message->setTown($location->getTown());
        $message->setCountry($location->getCountry());
        $message->setDefaultLocation($location->isDefaultLocation());
        $message->setLatitude($location->getLatitude());
        $message->setLongitude($location->getLongitude());

        foreach ($location->getTranslations() as $translation) {
            $transMessage = LocationTranslationMessage::createFromLocationTranslation($translation);

            $message->addTranslation($transMessage);
        }

        return $message;
    }
316059
public function addToSet($result, $field = null)
    {
        $field = $this->prepareField($field ?: $result);

        $this->fields[$result] = ['$addToSet' => $field];

        return $this;
    }
1234968
public function createResponse(array $result): Response
    {
        if (empty($this->deferred)) {
            return response($result);
        }

        return response()->stream(
            function () use ($result): void {
                $nested = 1;
                $this->result = $result;
                $this->isStreaming = true;
                $this->stream->stream($result, [], empty($this->deferred));

                if ($executionTime = config('lighthouse.defer.max_execution_ms', 0)) {
                    $this->maxExecutionTime = microtime(true) + ($executionTime * 1000);
                }

                // TODO: Allow nested_levels to be set in config
                // to break out of loop early.
                while (
                    count($this->deferred)
                    && ! $this->executionTimeExpired()
                    && ! $this->maxNestedFieldsResolved($nested)
                ) {
                    $nested++;
                    $this->executeDeferred();
                }

                // We've hit the max execution time or max nested levels of deferred fields.
                // We process remaining deferred fields, but are no longer allowing additional
                // fields to be deferred.
                if (count($this->deferred)) {
                    $this->acceptFurtherDeferring = false;
                    $this->executeDeferred();
                }
            },
            200,
            [
                // TODO: Allow headers to be set in config
                'X-Accel-Buffering' => 'no',
                'Content-Type' => 'multipart/mixed; boundary="-"',
            ]
        );
    }
66217
private function createCustomUrlRemoveForm(Location $location, array $customUrlAliases): FormInterface
    {
        $customUrlRemoveData = new CustomUrlRemoveData($location, $this->getChoices($customUrlAliases));

        return $this->formFactory->removeCustomUrl($customUrlRemoveData);
    }
1231755
public static function to($location, $data = null)
    {
        $location = ($location === '/') ? URL : URL . $location;

        $c = ($data) ? '?twigformfields='.base64_encode(json_encode($data)) : null;
        header('Location: ' . $location . $c);
        exit;
    }
940737
private function filesIterator(string $location, string $pattern = null): \GlobIterator
    {
        $pattern = $pattern ?? '*';
        $regexp = rtrim($location, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($pattern, DIRECTORY_SEPARATOR);

        return new \GlobIterator($regexp);
    }
939237
public function createNodeGathererTraverser($result, $containerNode)
    {
        $gatherer = new Traverser($result);
        $gatherer->addVisitor(
            function ($path, $node) use($containerNode) {
                $containerNode->append($node);
            },
            function ($path, $node) {
                return $node instanceof Node;
            },
            Traverser::AFTER
        );
        return $gatherer;
    }