コード例 #1
0
ファイル: One.php プロジェクト: Hlavos/obo
 /**
  * @param \obo\Entity $owner
  * @param mixed $propertyValue
  * @param boolean $autoCreate
  * @return \obo\Entity|null
  */
 public function relationshipForOwnerAndPropertyValue(\obo\Entity $owner, $propertyValue, $autoCreate = true)
 {
     $this->owner = $owner;
     if ($this->entityClassNameToBeConnectedInPropertyWithName === null) {
         $entityClassNameToBeConnected = $this->entityClassNameToBeConnected;
     } else {
         if (!($entityClassNameToBeConnected = $owner->valueForPropertyWithName($this->entityClassNameToBeConnectedInPropertyWithName))) {
             return null;
         }
     }
     $entityManagerName = $entityClassNameToBeConnected::entityInformation()->managerName;
     if ($propertyValue) {
         return $entityManagerName::entityWithPrimaryPropertyValue($propertyValue, true);
     } else {
         return ($autoCreate and $this->autoCreate and !$owner->isDeleted()) ? $entityManagerName::entityFromArray([]) : null;
     }
 }
コード例 #2
0
ファイル: IdentityMapper.php プロジェクト: Hlavos/obo
 /**
  * @param \obo\Entity $entity
  * @return string
  */
 public function identificationKeyForEntity(\obo\Entity $entity)
 {
     return $entity->className() . $entity->valueForPropertyWithName($entity->entityInformation()->primaryPropertyName);
 }
コード例 #3
0
ファイル: EntityManager.php プロジェクト: Hlavos/obo
 /**
  * @param \obo\Entity $entity
  * @param bool $ignoreSoftDelete
  * @return array;
  */
 protected static function rawDataForEntity(\obo\Entity $entity, $ignoreSoftDelete = false)
 {
     $primaryPropertyName = $entity->entityInformation()->primaryPropertyName;
     $specification = self::queryCarrier();
     $specification->select(self::constructSelect())->where("{{$primaryPropertyName}} = " . \obo\Interfaces\IQuerySpecification::PARAMETER_PLACEHOLDER, $entity->valueForPropertyWithName($primaryPropertyName));
     if (!$ignoreSoftDelete and ($propertyNameForSoftDelete = $entity->entityInformation()->propertyNameForSoftDelete) !== "") {
         $specification->where("AND {{$propertyNameForSoftDelete}} = " . \obo\Interfaces\IQuerySpecification::PARAMETER_PLACEHOLDER, FALSE);
     }
     $data = self::rawDataForSpecification($specification);
     return isset($data[0]) ? $data[0] : [];
 }