예제 #1
0
 /**
  * Move entity hierarchy to new parent or root
  *
  * @param ConfigEntity $config config object
  * @param string|null  $to     parent name
  * @return ConfigEntity
  * @throws InvalidArgumentException
  * @throws NoParentException
  */
 public function move(ConfigEntity $config, $to = null)
 {
     if ($to !== null && $this->repo->find($config->siteKey, $to) === null) {
         throw new InvalidArgumentException(['arg' => $to]);
     }
     $parent = $config->getParent();
     if ($parent === null) {
         if ($config->getDepth() !== 1) {
             throw new NoParentException();
         }
         $this->repo->affiliate($config, $to);
     } else {
         $this->repo->foster($config, $to);
     }
     $arrName = explode('.', $config->name);
     $key = array_pop($arrName);
     if ($to !== null) {
         $key = $to . '.' . $key;
     }
     return $this->get($key, false, $config->siteKey);
 }
 /**
  * search getter
  *
  * @param string $siteKey site key
  * @param string $name    the name
  * @return ConfigEntity
  */
 public function find($siteKey, $name)
 {
     return $this->repo->find($siteKey, $name);
 }