findItem() public method

Find a menu item
public findItem ( string $id, array $with = [] ) : MenuItem
$id string menu item identifier
$with array relation
return Xpressengine\Menu\Models\MenuItem
示例#1
0
 /**
  * Find a menu item
  *
  * @param string $id   menu item identifier
  * @param array  $with relation
  * @return MenuItem
  */
 public function findItem($id, $with = [])
 {
     if (!isset($this->itemBag[$id])) {
         $this->itemBag[$id] = $this->repo->findItem($id, $with);
     }
     return $this->itemBag[$id];
 }
示例#2
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;
     });
 }
示例#3
0
 /**
  * Get setting page url by menu item id
  *
  * @param string $itemId menu item identifier
  * @return string|null
  */
 public function getInstanceSettingURIByItemId($itemId)
 {
     if (!($item = $this->repo->findItem($itemId))) {
         return null;
     }
     return $this->getInstanceSettingURI($item);
 }
 /**
  * Find a menu item
  *
  * @param string $id   menu item identifier
  * @param array  $with relation
  * @return MenuItem
  */
 public function findItem($id, $with = [])
 {
     return $this->repo->findItem($id, $with);
 }