本文整理汇总了PHP中Doctrine\ORM\Event\LifecycleEventArgs::getEntityChangeSet方法的典型用法代码示例。如果您正苦于以下问题:PHP LifecycleEventArgs::getEntityChangeSet方法的具体用法?PHP LifecycleEventArgs::getEntityChangeSet怎么用?PHP LifecycleEventArgs::getEntityChangeSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Event\LifecycleEventArgs
的用法示例。
在下文中一共展示了LifecycleEventArgs::getEntityChangeSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preUpdate
/**
* Sets origin and destination coordinates before updating.
*
* Method will only call geocode() if one of the location fields was changed
* by the user.
*
* @param LifecycleEventArgs $eventArgs
*/
public function preUpdate(LifecycleEventArgs $eventArgs)
{
$object = $eventArgs->getEntity();
if ($object instanceof RouteAwareInterface) {
if (count(array_intersect(array_keys($eventArgs->getEntityChangeSet()), $this->originFields)) > 0) {
$this->updateOriginCoordinates($object);
$this->updateDistance($object);
}
if (count(array_intersect(array_keys($eventArgs->getEntityChangeSet()), $this->destinationFields)) > 0) {
$this->updateDestinationCoordinates($object);
$this->updateDistance($object);
}
}
}
示例2: preUpdate
/**
* Sets location coordinates before updating.
*
* Method will only call geocode() if one of the location fields was changed
* by the user.
*
* @param LifecycleEventArgs $eventArgs
*/
public function preUpdate(LifecycleEventArgs $eventArgs)
{
$object = $eventArgs->getEntity();
if ($object instanceof LocationAwareInterface) {
if (count(array_intersect(array_keys($eventArgs->getEntityChangeSet()), $this->locationFields)) > 0) {
$this->updateCoordinates($object);
}
}
}
示例3: preUpdate
public function preUpdate(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
$token = $this->container->get('security.token_storage')->getToken();
//OAuth
if (!$token) {
return;
}
$translator = $this->container->get('translator');
$annotations = $this->container->get('annotations');
$utils = $this->container->get('utils');
$className = $utils->getObjectClass($entity);
$changes = $args->getEntityChangeSet();
$meta = $annotations->getAll($className);
$log = '';
$idx = 1;
foreach ($changes as $field => $change) {
$fieldName = ucfirst(strtolower($field));
if (isset($meta['properties']['data'][$field])) {
$fieldName = $meta['properties']['data'][$field]->getTitle();
}
// было
if ($change[0] instanceof \DateTime) {
$was = $change[0]->format('Y-m-d H:is');
} else {
$was = $change[0];
}
// стало
if ($change[1] instanceof \DateTime) {
$became = $change[1]->format('Y-m-d H:is');
} else {
$became = $change[1];
}
$log .= "<strong>" . $translator->trans($fieldName, [], 'global') . "</strong><br />";
$log .= " - " . $translator->trans('It was', [], 'global') . ": " . $was . "<br />";
$log .= " - " . $translator->trans('It became', [], 'global') . ": " . $became . "<br />";
if ($idx < count($changes)) {
$log .= "<br />";
$idx++;
}
}
if ($this->skipCondition($entity)) {
$history = new History();
$history->setCreatedAt(new \DateTime());
$history->setUser($token->getUser());
$history->setEntityCode($utils->getUnderscore($className));
$history->setType('update');
$history->setEntryId($entity->getId());
$history->setLog($log);
$this->history[] = $history;
}
}
示例4: preUpdatePayment
/**
* preUpdatePayment
*
* @param LifecycleEventArgs $args
*/
protected function preUpdatePayment(LifecycleEventArgs $args)
{
$object = $args->getEntity();
$em = $args->getEntityManager();
$array_changes = $args->getEntityChangeSet();
//echo"<pre>";print_r($array_changes['paymentSystem'][0]->getName());echo"</pre>";exit;
if (isset($array_changes['amount']) or isset($array_changes['paymentSystem']) or isset($array_changes['flag'])) {
$uow = $em->getUnitOfWork();
$PaymentChanged = new \Rodina\CrmBundle\Entity\Abonent\PaymentChanged($object, isset($array_changes['amount']) ? $array_changes['amount'][0] : $object->getAmount(), isset($array_changes['comment']) ? $array_changes['comment'][0] : $object->getComment(), isset($array_changes['paySystem']) ? $array_changes['paySystem'][0] : $object->getPaySystem(), isset($array_changes['payType']) ? $array_changes['payType'][0] : $object->getPayType(), isset($array_changes['payServiceComment']) ? $array_changes['payServiceComment'][0] : $object->getPayServiceComment(), isset($array_changes['receipt']) ? $array_changes['receipt'][0] : $object->getReceipt(), isset($array_changes['payDate']) ? $array_changes['payDate'][0] : $object->getPayDate(), isset($array_changes['localDate']) ? $array_changes['localDate'][0] : $object->getLocalDate(), isset($array_changes['flag']) ? $array_changes['flag'][0] : $object->getFlag(), isset($array_changes['paymentSystem']) ? $array_changes['paymentSystem'][0] : $object->getPaymentSystem(), isset($array_changes['manager']) ? $array_changes['manager'][0] : $object->getManager());
$em->persist($PaymentChanged);
$object->addChange($PaymentChanged);
$uow->recomputeSingleEntityChangeSet($em->getClassMetadata("Rodina\\CrmBundle\\Entity\\Abonent\\Payment"), $object);
}
}