本文整理汇总了PHP中TYPO3\Flow\Persistence\PersistenceManagerInterface::add方法的典型用法代码示例。如果您正苦于以下问题:PHP PersistenceManagerInterface::add方法的具体用法?PHP PersistenceManagerInterface::add怎么用?PHP PersistenceManagerInterface::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Persistence\PersistenceManagerInterface
的用法示例。
在下文中一共展示了PersistenceManagerInterface::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Adds an object to this repository.
*
* @param object $object The object to add
* @return void
* @throws \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException
* @api
*/
public function add($object)
{
if (!is_object($object) || !$object instanceof $this->entityClassName) {
$type = is_object($object) ? get_class($object) : gettype($object);
throw new \TYPO3\Flow\Persistence\Exception\IllegalObjectTypeException('The value given to add() was ' . $type . ' , however the ' . get_class($this) . ' can only store ' . $this->entityClassName . ' instances.', 1298403438);
}
$this->persistenceManager->add($object);
}
示例2: getResourcePointerForHash
/**
* Helper function which creates or fetches a resource pointer object for a given hash.
*
* If a ResourcePointer with the given hash exists, this one is used. Else, a new one
* is created. This is a workaround for missing ValueObject support in Doctrine.
*
* @param string $hash
* @return \TYPO3\Flow\Resource\ResourcePointer
*/
public function getResourcePointerForHash($hash)
{
$resourcePointer = $this->persistenceManager->getObjectByIdentifier($hash, 'TYPO3\\Flow\\Resource\\ResourcePointer');
if (!$resourcePointer) {
$resourcePointer = new \TYPO3\Flow\Resource\ResourcePointer($hash);
$this->persistenceManager->add($resourcePointer);
}
return $resourcePointer;
}
示例3: persistEntities
/**
* Checks if a propertyValue contains an entity and persists it.
*
* @param mixed $propertyValue
* @return void
*/
protected function persistEntities($propertyValue)
{
if (!$propertyValue instanceof \Iterator && !is_array($propertyValue)) {
$propertyValue = array($propertyValue);
}
foreach ($propertyValue as $possibleEntity) {
if (is_object($possibleEntity) && $possibleEntity instanceof \TYPO3\Flow\Persistence\Aspect\PersistenceMagicInterface) {
$this->persistenceManager->isNewObject($possibleEntity) ? $this->persistenceManager->add($possibleEntity) : $this->persistenceManager->update($possibleEntity);
// TODO: Needed because the originalAsset will not cascade persist. We should find a generic solution to this.
if ($possibleEntity instanceof ImageVariant) {
$asset = $possibleEntity->getOriginalAsset();
$this->persistenceManager->isNewObject($asset) ? $this->persistenceManager->add($asset) : $this->persistenceManager->update($asset);
}
}
}
}
示例4: persistRelatedEntities
/**
* Checks if a property value contains an entity and persists it.
*
* @param mixed $value
*/
protected function persistRelatedEntities($value)
{
if (!is_array($value) && !$value instanceof \Iterator) {
$value = array($value);
}
foreach ($value as $element) {
if (is_object($element) && $element instanceof PersistenceMagicInterface) {
$this->persistenceManager->isNewObject($element) ? $this->persistenceManager->add($element) : $this->persistenceManager->update($element);
}
}
}
示例5: addObjectToPersistence
/**
* @param object $object
* @return void
*/
protected function addObjectToPersistence($object)
{
$this->persistenceManager->add($object);
}