has() public method

has
public has ( string $key ) : boolean
$key string key name
return boolean
Exemplo n.º 1
0
 /**
  * Find a menu item
  *
  * @param string $id   menu item identifier
  * @param array  $with relation
  * @return MenuItem
  */
 public function findItem($id, $with = [])
 {
     $key = $this->getItemCacheKey($id);
     return $this->cache->has($key) ? $this->cache->get($key) : call_user_func(function () use($key, $id, $with) {
         if ($menu = $this->repo->findItem($id, $with)) {
             $this->cache->put($key, $menu);
         }
         return $menu;
     });
 }
Exemplo n.º 2
0
 /**
  * Retrieve routes by module name
  *
  * @param string $module module name
  * @return InstanceRoute[]
  */
 public function fetchByModule($module)
 {
     $key = $this->getCacheKey($module);
     $routes = $this->cache->has($key) ? $this->cache->get($key) : call_user_func(function () use($module, $key) {
         $routes = $this->repo->fetchByModule($module);
         if (count($routes) > 0) {
             $this->cache->put($key, $routes);
         }
         return $routes;
     });
     return $routes;
 }