findByUrlAndSiteKey() публичный Метод

Retrieve a route by url segment and site key
public findByUrlAndSiteKey ( string $url, string $siteKey ) : InstanceRoute
$url string first segment of url
$siteKey string site key
Результат InstanceRoute
Пример #1
0
 /**
  * Retrieve a route by url segment and site key
  *
  * @param string $url     first segment of url
  * @param string $siteKey site key
  * @return InstanceRoute
  */
 public function findByUrlAndSiteKey($url, $siteKey)
 {
     if (!isset($this->mapBySiteKey[$siteKey]) || !array_key_exists($url, $this->mapBySiteKey[$siteKey])) {
         if (!($route = $this->repo->findByUrlAndSiteKey($url, $siteKey))) {
             return null;
         }
         $this->setToMap($route);
     }
     return $this->mapBySiteKey[$siteKey][$url];
 }
Пример #2
0
 /**
  * getInstanceRoute
  *
  * @param Request $request laravel request
  *
  * @return InstanceRoute
  */
 private function getInstanceRoute(Request $request)
 {
     $firstSegment = $request->segment(1);
     $siteKey = $this->siteHandler->getCurrentSiteKey();
     if ($firstSegment === null) {
         $instanceRoute = $this->getHomeInstanceRoute();
     } else {
         $instanceRoute = $this->routeRepo->findByUrlAndSiteKey($firstSegment, $siteKey);
     }
     return $instanceRoute;
 }
Пример #3
0
 /**
  * Retrieve a route by url segment and site key
  *
  * @param string $url     first segment of url
  * @param string $siteKey site key
  * @return InstanceRoute|null
  */
 public function findByUrlAndSiteKey($url, $siteKey)
 {
     $key = $this->getCacheKey($siteKey . '_' . $url);
     $route = $this->cache->has($key) ? $this->cache->get($key) : call_user_func(function () use($url, $siteKey) {
         if ($route = $this->repo->findByUrlAndSiteKey($url, $siteKey)) {
             $this->cachingItem($route);
         }
         return $route;
     });
     return $route;
 }