/** * make hierarchy to upper * * @param ConfigEntity $ancestor config object * @return void * @throws NotHasParentException */ public function setParent(ConfigEntity $ancestor) { if ($this->isAdjacency($ancestor->name, $this->name)) { $this->parent = $ancestor; } else { if (is_null($this->parent)) { throw new NotHasParentException('Parent is not exists'); } $this->parent->setParent($ancestor); } }
/** * ancestors setter * * @param ConfigEntity $config config instance * @return ConfigEntity */ private function setAncestors(ConfigEntity $config) { $ancestors = $this->repo->fetchParent($config->siteKey, $config->name); $ancestors = $this->sort($ancestors, 'desc'); foreach ($ancestors as $ancestor) { $this->bindClosure($ancestor); $config->setParent($ancestor); } return $config; }