public function matchesPath() { $urlFrom = $this->map->getUrlFrom(); $requestUri = $this->request->getRequestUri(); if (!$this->map->getUrlFromIsRegexPattern()) { $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; return $this->map->getUrlFromIsNoCase() ? $strtolower($urlFrom) === $strtolower($requestUri) : $urlFrom === $requestUri; } $regexModifier = $this->map->getUrlFromIsNoCase() ? 'i' : ''; return preg_match('#' . $urlFrom . '#' . $regexModifier, $requestUri, $this->patternMatches); }
/** * Check for circular redirects etc * @param Map $map * @return boolean */ public function validate(Map $map) { if ($map->getUrlFrom() == $map->getUrlTo()) { return false; } $self = $this; $accumulator = []; if ($map->getId()) { $accumulator = [$map->getId() => $map->getId()]; } $recurse = function (Map $map, Map $startPointMap) use($self, &$recurse, &$accumulator) { $matchingToUrls = $self->mapRepository->findForUrlOrPath($map->getUrlTo(), $map->getUrlTo(), $accumulator); foreach ($matchingToUrls as $match) { $accumulator[$match->getId()] = $match->getId(); if ($startPointMap->getUrlFrom() == $match->getUrlTo()) { return false; } elseif ($match->getUrlFrom() == $map->getUrlTo()) { return $recurse($match, $startPointMap); } } return true; }; return $recurse($map, $map); }