concrete/src/Url/SeoCanonical.php
public function getPageCanonicalURL($page, $querystring = null)
    {
        $result = null;
        if ($page) {
            if ($this->valn->integer($page, 1)) {
                $page = Page::getByID($page);
            }
            if ($page instanceof Page && !$page->isError()) {
                $cID = $page->getCollectionID();
                $originalCID = $page->getCollectionPointerOriginalID();
                if (!empty($originalCID) && $originalCID != $cID) {
                    $result = $this->getPageCanonicalURL($cID, $querystring);
                } else {
                    $result = $this->resolver->resolve([$page]);
                    $query = null;
                    if ($querystring instanceof Query) {
                        $query = clone $querystring;
                    } elseif ($querystring instanceof Request) {
                        $query = new Query($querystring->query->all());
                    } elseif ($querystring instanceof ParameterBag) {
                        $query = new Query($querystring->all());
                    } elseif (is_array($querystring)) {
                        $query = new Query($querystring);
                    } elseif (is_string($querystring)) {
                        if ($querystring !== '') {
                            $query = new Query($querystring);
                        }
                    }
                    if ($query !== null && $query->count() > 0) {
                        foreach ($this->excludedQuerystringParameters as $qp) {
                            $query->offsetUnset($qp);
                        }
                        $result = $result->setQuery($query);
                    }
                }
            }
        }

        return $result;
    }
public function getPageCanonicalURL($page, $querystring = null)
    {
        $result = null;
        if ($page) {
            if ($this->valn->integer($page, 1)) {
                $page = Page::getByID($page);
            }
            if ($page instanceof Page && !$page->isError()) {
                $cID = $page->getCollectionID();
                $originalCID = $page->getCollectionPointerOriginalID();
                if (!empty($originalCID) && $originalCID != $cID) {
                    $result = $this->getPageCanonicalURL($cID, $querystring);
                } else {
                    $result = $this->resolver->resolve([$page]);
                    $query = null;
                    if ($querystring instanceof Query) {
                        $query = clone $querystring;
                    } elseif ($querystring instanceof Request) {
                        $query = new Query($querystring->query->all());
                    } elseif ($querystring instanceof ParameterBag) {
                        $query = new Query($querystring->all());
                    } elseif (is_array($querystring)) {
                        $query = new Query($querystring);
                    } elseif (is_string($querystring)) {
                        if ($querystring !== '') {
                            $query = new Query($querystring);
                        }
                    }
                    if ($query !== null && $query->count() > 0) {
                        foreach ($this->excludedQuerystringParameters as $qp) {
                            $query->offsetUnset($qp);
                        }
                        $result = $result->setQuery($query);
                    }
                }
            }
        }

        return $result;
    }
public function getPageCanonicalURL ( $ page , $ querystring = null ) { $ result = null ; if ( $ page ) { if ( $ this -> valn -> integer ( $ page , 1 ) ) { $ page = Page :: getByID ( $ page ) ; } if ( $ page instanceof Page && ! $ page -> isError ( ) ) { $ cID = $ page -> getCollectionID ( ) ; $ originalCID = $ page -> getCollectionPointerOriginalID ( ) ; if ( ! empty ( $ originalCID ) && $ originalCID != $ cID ) { $ result = $ this -> getPageCanonicalURL ( $ cID , $ querystring ) ; } else { $ result = $ this -> resolver -> resolve ( [ $ page ] ) ; $ query = null ; if ( $ querystring instanceof Query ) { $ query = clone $ querystring ; } elseif ( $ querystring instanceof Request ) { $ query = new Query ( $ querystring -> query -> all ( ) ) ; } elseif ( $ querystring instanceof ParameterBag ) { $ query = new Query ( $ querystring -> all ( ) ) ; } elseif ( is_array ( $ querystring ) ) { $ query = new Query ( $ querystring ) ; } elseif ( is_string ( $ querystring ) ) { if ( $ querystring !== '' ) { $ query = new Query ( $ querystring ) ; } } if ( $ query !== null && $ query -> count ( ) > 0 ) { foreach ( $ this -> excludedQuerystringParameters as $ qp ) { $ query -> offsetUnset ( $ qp ) ; } $ result = $ result -> setQuery ( $ query ) ; } } } } return $ result ; }
Generate the canonical URL of a page.

@param Page|int $page The Page instance (or its collection ID)
@param Request|ParameterBag|Query|array|string|null $querystring Optional query string parameters

@return \League\URL\URLInterface|null
Generate the canonical URL of a page .