bundle/Controller/FullViewController.php
protected function checkCategoryRedirect(Location $location): ?RedirectResponse
    {
        $content = $location->content;

        $internalRedirectContent = null;
        if (!$content->getField('internal_redirect')->isEmpty()) {
            $internalRedirectContent = $content->getFieldRelation('internal_redirect');
        }

        $externalRedirectValue = $content->getField('external_redirect')->value;

        if ($internalRedirectContent instanceof Content) {
            if ($internalRedirectContent->contentInfo->mainLocationId !== $location->id) {
                return new RedirectResponse(
                    $this->router->generate($internalRedirectContent),
                    RedirectResponse::HTTP_MOVED_PERMANENTLY
                );
            }
        } elseif ($externalRedirectValue instanceof UrlValue && !$content->getField('external_redirect')->isEmpty()) {
            if (mb_stripos($externalRedirectValue->link, 'http') === 0) {
                return new RedirectResponse($externalRedirectValue->link, RedirectResponse::HTTP_MOVED_PERMANENTLY);
            }

            return new RedirectResponse(
                $this->router->generate($this->getRootLocation()) . trim($externalRedirectValue->link, '/'),
                RedirectResponse::HTTP_MOVED_PERMANENTLY
            );
        }

        return null;
    }
protected function checkCategoryRedirect(Location $location): ?RedirectResponse
    {
        $content = $location->content;

        $internalRedirectContent = null;
        if (!$content->getField('internal_redirect')->isEmpty()) {
            $internalRedirectContent = $content->getFieldRelation('internal_redirect');
        }

        $externalRedirectValue = $content->getField('external_redirect')->value;

        if ($internalRedirectContent instanceof Content) {
            if ($internalRedirectContent->contentInfo->mainLocationId !== $location->id) {
                return new RedirectResponse(
                    $this->router->generate($internalRedirectContent),
                    RedirectResponse::HTTP_MOVED_PERMANENTLY
                );
            }
        } elseif ($externalRedirectValue instanceof UrlValue && !$content->getField('external_redirect')->isEmpty()) {
            if (mb_stripos($externalRedirectValue->link, 'http') === 0) {
                return new RedirectResponse($externalRedirectValue->link, RedirectResponse::HTTP_MOVED_PERMANENTLY);
            }

            return new RedirectResponse(
                $this->router->generate($this->getRootLocation()) . trim($externalRedirectValue->link, '/'),
                RedirectResponse::HTTP_MOVED_PERMANENTLY
            );
        }

        return null;
    }
protected function checkCategoryRedirect ( Location $ location ) : ? RedirectResponse { $ content = $ location -> content ; $ internalRedirectContent = null ; if ( ! $ content -> getField ( 'internal_redirect' ) -> isEmpty ( ) ) { $ internalRedirectContent = $ content -> getFieldRelation ( 'internal_redirect' ) ; } $ externalRedirectValue = $ content -> getField ( 'external_redirect' ) -> value ; if ( $ internalRedirectContent instanceof Content ) { if ( $ internalRedirectContent -> contentInfo -> mainLocationId !== $ location -> id ) { return new RedirectResponse ( $ this -> router -> generate ( $ internalRedirectContent ) , RedirectResponse :: HTTP_MOVED_PERMANENTLY ) ; } } elseif ( $ externalRedirectValue instanceof UrlValue && ! $ content -> getField ( 'external_redirect' ) -> isEmpty ( ) ) { if ( mb_stripos ( $ externalRedirectValue -> link , 'http' ) === 0 ) { return new RedirectResponse ( $ externalRedirectValue -> link , RedirectResponse :: HTTP_MOVED_PERMANENTLY ) ; } return new RedirectResponse ( $ this -> router -> generate ( $ this -> getRootLocation ( ) ) . trim ( $ externalRedirectValue -> link , '/' ) , RedirectResponse :: HTTP_MOVED_PERMANENTLY ) ; } return null ; }
Checks if content at location defined by it's ID contains
valid category redirect value and returns a redirect response if it does.
Checks if content at location defined by it s ID contains valid category redirect value and returns a redirect response if it does .