public \Joomla\CMS\Component\Router\RouterViewConfiguration
setParent
(\Joomla\CMS\Component\Router\RouterViewConfiguration $parent, mixed $parentKey = null)
/**
* Set the parent view of this view
*
* @param RouterViewConfiguration $parent Parent view object
* @param string $parentKey Key of the parent view in this context
*
* @return RouterViewConfiguration This object for chaining
*
* @since 3.5
*/
public function setParent(RouterViewConfiguration $parent, $parentKey = null)
{
if ($this->parent) {
$key = array_search($this, $this->parent->children);
if ($key !== false) {
unset($this->parent->children[$key]);
}
if ($this->parent_key) {
$child_key = array_search($this->parent_key, $this->parent->child_keys);
unset($this->parent->child_keys[$child_key]);
}
}
$this->parent = $parent;
$parent->children[] = $this;
$this->path = $parent->path;
$this->path[] = $this->name;
$this->parent_key = $parentKey ?? false;
if ($parentKey) {
$parent->child_keys[] = $parentKey;
}
return $this;
}