concrete/src/Page/Sitemap/SitemapGenerator.php
protected function withCustomCanonicalUrl(callable $run)
    {
        $customCanonicalUrl = $this->getCustomSiteCanonicalUrl();
        if ($customCanonicalUrl !== '') {
            $siteConfig = $this->getPageListGenerator()->getSite()->getConfigRepository();
            $originalSiteCanonicalUrl = $siteConfig->get('seo.canonical_url');
            $siteConfig->set('seo.canonical_url', $customCanonicalUrl);
        }
        try {
            return $run();
        } finally {
            if ($customCanonicalUrl !== '') {
                $siteConfig->set('seo.canonical_url', $originalSiteCanonicalUrl);
            }
        }
    }
protected function withCustomCanonicalUrl(callable $run)
    {
        $customCanonicalUrl = $this->getCustomSiteCanonicalUrl();
        if ($customCanonicalUrl !== '') {
            $siteConfig = $this->getPageListGenerator()->getSite()->getConfigRepository();
            $originalSiteCanonicalUrl = $siteConfig->get('seo.canonical_url');
            $siteConfig->set('seo.canonical_url', $customCanonicalUrl);
        }
        try {
            return $run();
        } finally {
            if ($customCanonicalUrl !== '') {
                $siteConfig->set('seo.canonical_url', $originalSiteCanonicalUrl);
            }
        }
    }
protected function withCustomCanonicalUrl ( callable $ run ) { $ customCanonicalUrl = $ this -> getCustomSiteCanonicalUrl ( ) ; if ( $ customCanonicalUrl !== '' ) { $ siteConfig = $ this -> getPageListGenerator ( ) -> getSite ( ) -> getConfigRepository ( ) ; $ originalSiteCanonicalUrl = $ siteConfig -> get ( 'seo.canonical_url' ) ; $ siteConfig -> set ( 'seo.canonical_url' , $ customCanonicalUrl ) ; } try { return $ run ( ) ; } finally { if ( $ customCanonicalUrl !== '' ) { $ siteConfig -> set ( 'seo.canonical_url' , $ originalSiteCanonicalUrl ) ; } } }
Don't use with generators!

@param callable $run
Don t use with generators!