本文整理汇总了PHP中Doctrine\ORM\UnitOfWork::propertyChanged方法的典型用法代码示例。如果您正苦于以下问题:PHP UnitOfWork::propertyChanged方法的具体用法?PHP UnitOfWork::propertyChanged怎么用?PHP UnitOfWork::propertyChanged使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\UnitOfWork
的用法示例。
在下文中一共展示了UnitOfWork::propertyChanged方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onFlushForUpdates
/**
* Flush for update
*
* @param object $entity
* @param \Doctrine\ORM\EntityManager $entityManager
* @param \Doctrine\ORM\UnitOfWork $unitOfWork
*/
protected function onFlushForUpdates(&$entity, EntityManager &$entityManager, UnitOfWork &$unitOfWork)
{
$className = get_class($entity);
$this->initializeAnnotationsForEntity($className);
if (count(self::$storedProperties[$className]['annotations']) > 0) {
foreach (self::$storedProperties[$className]['annotations'] as $propertyName => &$annotations) {
/* @var $annotation Traceable */
foreach ($annotations as $annotation) {
$run = $annotation->on === 'update';
if ($annotation->on === 'change') {
$changeSet = $unitOfWork->getEntityChangeSet($entity);
if (isset($changeSet[$annotation->field])) {
$type = $this->getPropertyType($className, $annotation->field);
$values = $annotation->getFieldValues($type, $entity);
$run = count($values) === 0 || in_array($changeSet[$annotation->field][1], $values);
}
}
if ($run) {
list($oldValue, $value) = $this->updateEntityPropertyValue($entity, $className, $propertyName, $annotation);
$entityManager->persist($entity);
$unitOfWork->propertyChanged($entity, $propertyName, $oldValue, $value);
$unitOfWork->scheduleExtraUpdate($entity, array($propertyName => array($oldValue, $value)));
break;
}
}
}
}
}
示例2: updateField
/**
* Updates a field
*
* @param ORM\UnitOfWork $uow
* @param mixed $object
* @param ORM\Mapping\ClassMetadata $classMetadata
* @param string $field
*/
private function updateField(ORM\UnitOfWork $uow, $object, ORM\Mapping\ClassMetadata $classMetadata, $field)
{
$property = $classMetadata->getReflectionProperty($field);
$oldValue = $property->getValue($object);
$newValue = $this->getDateValue($classMetadata, $field);
$property->setValue($object, $newValue);
$uow->propertyChanged($object, $field, $oldValue, $newValue);
$uow->scheduleExtraUpdate($object, [$field => [$oldValue, $newValue]]);
}
示例3: serialize
/**
* Serialize data of WorkflowItem
*
* @param WorkflowItem $workflowItem
* @param UnitOfWork $uow
*/
protected function serialize(WorkflowItem $workflowItem, UnitOfWork $uow)
{
if ($workflowItem->getData()->isModified()) {
$oldValue = $workflowItem->getSerializedData();
$this->serializer->setWorkflowName($workflowItem->getWorkflowName());
$serializedData = $this->serializer->serialize($workflowItem->getData(), $this->format);
$workflowItem->setSerializedData($serializedData);
$uow->propertyChanged($workflowItem, 'serializedData', $oldValue, $serializedData);
}
}