fetchDescendant() public method

Returns descendant of item
public fetchDescendant ( string $siteKey, string $name ) : array
$siteKey string site key
$name string target name
return array
コード例 #1
0
 /**
  * Returns descendant of item
  *
  * @param Permission $item permission instance
  * @return array
  */
 public function fetchDescendant(Permission $item)
 {
     $key = $this->getCacheKey($item->siteKey, $item->name, 'descendant');
     if (!($descendants = $this->cache->get($key))) {
         $descendants = $this->repo->fetchDescendant($item);
         if (!empty($descendants)) {
             $this->cache->put($key, $descendants);
         }
     }
     return $descendants;
 }
コード例 #2
0
 /**
  * get cached data
  *
  * @param string $siteKey site key
  * @param string $head    root name
  * @return array
  */
 protected function getData($siteKey, $head)
 {
     $key = $this->makeKey($siteKey, $head);
     if (!isset($this->bag[$key])) {
         $cacheKey = $this->getCacheKey($key);
         if (!($data = $this->cache->get($cacheKey))) {
             if (!($item = $this->repo->findByName($siteKey, $head))) {
                 return [];
             }
             $descendant = $this->repo->fetchDescendant($siteKey, $head);
             $data = array_merge([$item], $descendant);
             $this->cache->put($cacheKey, $data);
         }
         $this->bag[$key] = $data;
     }
     return $this->bag[$key];
 }
コード例 #3
0
 /**
  * Returns descendant of item
  *
  * @param Permission $item permission instance
  * @return array
  */
 public function fetchDescendant(Permission $item)
 {
     return $this->repo->fetchDescendant($item);
 }