/**
  * @param \obo\Entity $entity
  * @return void
  */
 public function insertEntity(\obo\Entity $entity)
 {
     if ($entity->isBasedInRepository()) {
         throw new \obo\Exceptions\Exception("Can't insert entity into storage. Entity is already persisted.");
     }
     $this->dibiConnection->query("INSERT INTO [{$entity->entityInformation()->repositoryName}] ", $this->convertDataForImport($entity->changedProperties($entity->entityInformation()->persistablePropertiesNames, true, true), $entity->entityInformation()));
     if ($autoIncrementProperty = $this->informations[$entity->entityInformation()->className]["autoIncrementProperty"]) {
         $entity->setValueForPropertyWithName($this->dibiConnection->getInsertId(), $autoIncrementProperty);
     }
 }
Beispiel #2
0
 public function remove(\obo\Entity $entity)
 {
     if ($this->connectViaPropertyWithName !== "") {
         $entity->setValueForPropertyWithName(null, $this->connectViaPropertyWithName);
         $entity->save();
     } elseif ($this->connectViaRepositoryWithName !== "") {
         $ownerManagerName = $this->owner->entityInformation()->managerName;
         $ownerManagerName::dataStorage()->removeRelationshipBetweenEntities($this->connectViaRepositoryWithName, [$this->owner, $entity]);
     } else {
         throw new \obo\Exceptions\Exception("This relationship is not well configured");
     }
 }