Calculates the URL to which visitor should be redirected according to
content's & visitor's language.

@param \Cake\Datasource\EntityInterface $content Content to inspect
@return string Redirection URL, empty on error
7280
protected function _calculateRedirection(EntityInterface $content)
    {
        foreach (['translation', 'parent'] as $method) {
            if ($has = $content->{$method}()) {
                return option('url_locale_prefix') ? '/' . $has->get('language') . stripLanguagePrefix($has->get('url')) : $has->get('url');
            }
        }

        return '';
    }
1027581
protected function rewriteImagesPathForProduction($content)
    {
        $imagesSourcePath = $this->imagesSourcePath;
        $imagesTargetPath = $this->imagesTargetPath;

        return preg_replace_callback('/([\/]?)(' . str_replace('/', '\/', $imagesSourcePath) . ')/s', function ($matches) use ($imagesTargetPath) {return $matches[1].$imagesTargetPath;}, $content);
    }
749844
public static function getIndent($content)
    {
        $indent = self::DEFAULT_INDENT;
        preg_match(self::INDENT_REGEX, trim($content), $matches);

        if (!empty($matches)) {
            $indent = \strlen($matches[1]);
        }

        return $indent;
    }
70247
public static function fromSymfonyParamsFile($content)
    {
        $params = Yaml::parse($content);

        if (!isset($params['parameters'])) {
            throw new \InvalidArgumentException('Symfony parameters file is invalid: unable to find root element "parameters".');
        }

        $params = $params['parameters'];

        foreach (self::$requiredSymfonyParams as $param) {
            if (!isset($params[$param])) {
                throw new \InvalidArgumentException(
                    sprintf('Unable to create MySQL credentials object from Symfony parameters: required parameter "%s" is missing.', $param)
                );
            }
        }

        $credentials = new self();

        foreach (self::$symfonyParamMap as $property => $param) {
            if (isset($params[$param])) {
                $credentials->$property = $params[$param];
            }
        }

        return $credentials;
    }
254833
public function parseNoTemplate($content) {
        $this->_content = $content;
        $this->_parseDebugStart();
        $this->_parseExtend();
        $this->_parseInclude();
        $this->_parsePath();
        $this->_parseGravatar();
        $this->_parseAsset();
        $this->_parseUrl();
        $this->_parsePhp();
        $this->_parseLang();
        $this->_parseForeach();
        $this->_parseFor();
        $this->_parseVar();
        $this->_parseVarFunc();
        $this->_parseCondition();
        $this->_parseFunction();
        $this->_parseException();
        $this->_parseMinify();
        $this->_parseDebugEnd();

        return $this->_content;
    }
842446
protected function proccessResult($content){
        $obj = json_decode($content, true);

        if($obj === null){
            $obj = array(
                'content' => $content
            );
        }

        return $obj;
    }
849020
protected function rewriteLinksForProduction($content)
    {
        $urlManager = $this->urlManager;

        $content = preg_replace_callback('/(\<a[^\>]+href[="\s]+)([^"\s]+)?([^\>]+\>)/s', function ($matches) use ($urlManager) {
            $url = $matches[2];

            if (preg_match('/route:([^"]+)/i', $url, $route)) {
                $url = sprintf("{{ path(%s) }}", html_entity_decode($route[1], ENT_QUOTES));

                return $matches[1] . $url . $matches[3];
            }

            $route = $urlManager
                ->fromUrl($url)
                ->getProductionRoute();

            if (null !== $route) {
                $url = sprintf("{{ path('%s') }}", $route);
            }

            return $matches[1] . $url . $matches[3];
        }, $content);

        return $content;
    }
1360382
protected function applySiteSpecificFilters($content)
    {
        $filters = $this->getSiteSpecificFilters();

        $from = array_keys($filters);
        $to = array_values($filters);

        return str_replace($from, $to, $content);
    }
812389
public static function entitiesToUnicode($content)
    {
        /* Convert HTML entities to uppercase hexadecimal */
        $content = preg_replace_callback('/\&\#(x?[a-zA-Z0-9]*?)\;/', function($matches) {
            $code = $matches[1];

            if ($code[0] == 'x') {
                return '&#x' . strtoupper(substr($code, 1)) . ';';
            }

            return '&#x' . strtoupper(dechex($code)) . ';';
        }, $content);

        $replacements = self::getEntityCodepoints();
        return str_replace(array_keys($replacements), $replacements, $content);
    }
757990
public function edit($content)
    {
        $content = $this->_defaultData($content);
        $link = str_replace('internal://', '', $content['link'], $count);
        $content['link'] = ($count > 0) ? '' : $content['link'];
        $this->_editViewData['targetOptions'] = [0 => 'Target: Same Tab', '_blank' => 'Target: New Tab'];
        $this->_editViewData['selectedPage'] = ($count > 0) ? $link : 0;
        $this->_editViewData['pageList'] = [0 => 'Custom Link: '] + Page::get_page_list();
        return parent::edit($content);
    }
81361
protected function _checkUrl(ServerRequestInterface $request)
    {
        return $this->_getUrlChecker()->check(
            $request,
            $this->getConfig('loginUrl'),
            (array)$this->getConfig('urlChecker')
        );
    }
551431
public function parseContent($content)
    {
        $cto = $this->getContentTypeObject();
        if (!empty($cto)) {
            return $cto->parseContent($content);
        } else {
            return $content;
        }
    }
25935
public function convert($content)
    {
        $result = strtr($content, $this->rules);
        return $this->correct($result);
    }
920896
public function compile($content)
    {
        if( ! $this->count()) return $content;

        $pattern = $this->getRegex();

        return preg_replace_callback("/{$pattern}/s", [&$this, 'render'], $content);
    }
393343
public function GetReferencedContainer(Content $content)
    {
        $contentContainer = ContentContainer::Schema()->ByContent($content);
        return $contentContainer ? $contentContainer->GetContainer() : null;
    }
1109804
protected function parseContent($content) {
        if(is_bool($content)) {
            $this->addLanguage($this->language, $content);
            return;
        }
        if (!$content) {
            return;
        }
        if (is_string($content)) {
            $this->addLanguage($this->language, $content);
            return;
        }
        foreach($content as $key => $data) {
            if (!empty($data[0]['sys']['linkType'])) {
                foreach($data as $link) {
                    $this->addLink($link['id'], $link['linkType'], $key);
                }
            } else {
                if (is_numeric($key)) {
                    $this->addLanguage($this->language, [$data]);
                } else {
                    $this->addLanguage($key, $data);
                }
            }
        }
    }
934018
protected function getRedirectUrl($context = null)
    {
        $redirectContext = explode('-', $context, 2)[0];
        $redirectSource = ends_with($context, '-close') ? 'redirectClose' : 'redirect';

        // Get the redirect for the provided context
        $redirects = [$context => $this->getConfig("{$redirectContext}[{$redirectSource}]", '')];

        // Assign the default redirect afterwards to prevent the
        // source for the default redirect being default[redirect]
        $redirects['default'] = $this->getConfig('defaultRedirect', '');

        if (empty($redirects[$context])) {
            return $redirects['default'];
        }

        return $redirects[$context];
    }