Source of file RootURLControllerExtension.php
Size: 0,788 Bytes - Last Modified: 2021-12-23T10:31:57+00:00
/var/www/docs.ssmods.com/process/src/code/RootURLControllerExtension.php
12345678910111213141516171819202122232425262728293031323334 | <?php namespace Twohill\HomepageForDomain; use SilverStripe\Core\Extension; use SilverStripe\CMS\Model\SiteTree; class RootURLControllerExtension extends Extension { /** * @param $link * @return string */ public function updateHomepageLink(&$link) { $host = str_replace('www.', null, $_SERVER['HTTP_HOST']); $candidates = SiteTree::get()->where([ '"SiteTree"."HomepageForDomain" LIKE ?' => "%$host%" ]); /** @var SiteTree $candidate */ foreach ($candidates as $candidate) { if (preg_match('/(,|^) *' . preg_quote($host) . ' *(,|$)/', $candidate->HomepageForDomain)) { $link = trim($candidate->RelativeLink(true), '/'); } } return $link; } } |