Beispiel #1
0
 /**
  * @test
  */
 public function isRelationiOwnedByParentCanBeSetToTrue()
 {
     $this->subject->markAsOwnedByParent();
     self::assertTrue($this->subject->isRelationOwnedByParent());
 }
Beispiel #2
0
 /**
  * Clone.
  *
  * @throws \BadMethodCallException
  */
 public function __clone()
 {
     if ($this->isReadOnly()) {
         throw new \BadMethodCallException('Read-only models cannot be cloned.', 1436453245);
     }
     if ($this->isDead()) {
         throw new \BadMethodCallException('Deleted models cannot be cloned.', 1436453107);
     }
     if ($this->isLoading()) {
         throw new \BadMethodCallException('Models cannot be cloned while they are loading.', 1436453245);
     }
     if ($this->isGhost()) {
         $this->load();
     }
     $this->resetUid();
     /** @var int|string|bool|float|null|Tx_Oelib_List|Tx_Oelib_Model $dataItem */
     foreach ($this->data as $key => $dataItem) {
         if ($dataItem instanceof Tx_Oelib_List) {
             /** Tx_Oelib_List $dataItem */
             if ($dataItem->isRelationOwnedByParent()) {
                 $newDataItem = new Tx_Oelib_List();
                 $newDataItem->markAsOwnedByParent();
                 /** @var Tx_Oelib_Model $childModel */
                 foreach ($dataItem as $childModel) {
                     $newDataItem->add(clone $childModel);
                 }
             } else {
                 $newDataItem = clone $dataItem;
             }
             $newDataItem->setParentModel($this);
             $this->set($key, $newDataItem);
         }
     }
     $this->markAsDirty();
 }