/** * Finds an object matching the given identifier. * * @param mixed $identifier The identifier of the object to find * @return object The matching object if found, otherwise NULL * @api */ public function findByIdentifier($identifier) { /** * @todo: This method must be changed again in 6.2 + 1 * This is marked @deprecated to be found in cleanup sessions. * * The repository should directly talk to the backend which * does not respect query settings of the repository as * findByIdentifier is strictly defined by finding an * undeleted object by its identifier regardless if it * is hidden/visible or a versioning/translation overlay. * * As a consequence users will be forced to overwrite this method * and mimic this behaviour to be able to find objects by identifier * respecting their query settings from 6.1 + 1 on. */ if ($this->session->hasIdentifier($identifier, $this->objectType)) { $object = $this->session->getObjectByIdentifier($identifier, $this->objectType); } else { $query = $this->createQuery(); $query->getQuerySettings()->setRespectStoragePage(FALSE); $query->getQuerySettings()->setRespectSysLanguage(FALSE); $object = $query->matching($query->equals('uid', $identifier))->execute()->getFirst(); } return $object; }
/** * Returns the object with the (internal) identifier, if it is known to the * backend. Otherwise NULL is returned. * * @param mixed $identifier * @param string $objectType * @param bool $useLazyLoading Set to TRUE if you want to use lazy loading for this object * @return object The object for the identifier if it is known, or NULL * @api */ public function getObjectByIdentifier($identifier, $objectType = null, $useLazyLoading = false) { if (isset($this->newObjects[$identifier])) { return $this->newObjects[$identifier]; } if ($this->persistenceSession->hasIdentifier($identifier, $objectType)) { return $this->persistenceSession->getObjectByIdentifier($identifier, $objectType); } else { return $this->backend->getObjectByIdentifier($identifier, $objectType); } }
/** * Returns the object with the (internal) identifier, if it is known to the * backend. Otherwise NULL is returned. * * @param string $identifier * @param string $className * @return object|NULL The object for the identifier if it is known, or NULL */ public function getObjectByIdentifier($identifier, $className) { if ($this->session->hasIdentifier($identifier, $className)) { return $this->session->getObjectByIdentifier($identifier, $className); } else { $query = $this->persistenceManager->createQueryForType($className); $query->getQuerySettings()->setRespectStoragePage(false); $query->getQuerySettings()->setRespectSysLanguage(false); return $query->matching($query->equals('uid', $identifier))->execute()->getFirst(); } }
/** * Returns the mapped classProperty from the identiyMap or * mapResultToPropertyValue() * * If the field value is empty and the column map has no parent key field name, * the relation will be empty. If the persistence session has a registered object of * the correct type and identity (fieldValue), this function returns that object. * Otherwise, it proceeds with mapResultToPropertyValue(). * * @param DomainObjectInterface $parentObject * @param string $propertyName * @param mixed $fieldValue the raw field value * @return mixed * @see mapResultToPropertyValue() */ protected function mapObjectToClassProperty(DomainObjectInterface $parentObject, $propertyName, $fieldValue) { if ($this->propertyMapsByForeignKey($parentObject, $propertyName)) { $result = $this->fetchRelated($parentObject, $propertyName, $fieldValue); $propertyValue = $this->mapResultToPropertyValue($parentObject, $propertyName, $result); } else { if ($fieldValue === '') { $propertyValue = $this->getEmptyRelationValue($parentObject, $propertyName); } else { $propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName); if ($this->persistenceSession->hasIdentifier($fieldValue, $propertyMetaData['type'])) { $propertyValue = $this->persistenceSession->getObjectByIdentifier($fieldValue, $propertyMetaData['type']); } else { $result = $this->fetchRelated($parentObject, $propertyName, $fieldValue); $propertyValue = $this->mapResultToPropertyValue($parentObject, $propertyName, $result); } } } return $propertyValue; }
/** * Checks whether the given UUID is known to the identity map * * @param string $uuid * @param string $className * @return boolean * @deprecated since 6.1, will be removed two versions later, use the persistence session instead */ public function hasIdentifier($uuid, $className) { return $this->persistenceSession->hasIdentifier($uuid, $className); }