コード例 #1
0
ファイル: fieldset.php プロジェクト: takawasitobi/pembit
 /**
  * Set the parent Fieldset instance
  *
  * @param   Fieldset  parent fieldset to which this belongs
  * @return  Fieldset
  */
 public function set_parent(Fieldset $fieldset)
 {
     if (!empty($this->fieldset_parent)) {
         throw new \RuntimeException('Fieldset already has a parent, belongs to "' . $this->parent()->name . '".');
     }
     $children = $fieldset->children();
     while ($child = array_shift($children)) {
         if ($child === $this) {
             throw new \RuntimeException('Circular reference detected, adding a Fieldset that\'s already a child as a parent.');
         }
         $children = array_merge($child->children(), $children);
     }
     $this->fieldset_parent = $fieldset;
     $fieldset->add_child($this);
     return $this;
 }