本文整理汇总了PHP中Doctrine\ORM\Event\PreUpdateEventArgs::getEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP PreUpdateEventArgs::getEntity方法的具体用法?PHP PreUpdateEventArgs::getEntity怎么用?PHP PreUpdateEventArgs::getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Event\PreUpdateEventArgs
的用法示例。
在下文中一共展示了PreUpdateEventArgs::getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preUpdate
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
$order = $eventArgs->getEntity();
if (!$order instanceof \Shopware\Models\Order\Order) {
return;
}
//order or payment status changed?
if ($eventArgs->hasChangedField('paymentStatus') || $eventArgs->hasChangedField('orderStatus')) {
$historyData = array('userID' => null, 'change_date' => date('Y-m-d H:i:s'), 'orderID' => $order->getId());
if (Shopware()->Auth()->getIdentity() && Shopware()->Auth()->getIdentity()->id) {
$user = $eventArgs->getEntityManager()->find('Shopware\\Models\\User\\User', Shopware()->Auth()->getIdentity()->id);
$historyData['userID'] = $user->getId();
}
//order status changed?
if ($eventArgs->hasChangedField('orderStatus')) {
$historyData['previous_order_status_id'] = $eventArgs->getOldValue('orderStatus')->getId();
$historyData['order_status_id'] = $eventArgs->getNewValue('orderStatus')->getId();
} else {
$historyData['previous_order_status_id'] = $order->getOrderStatus()->getId();
$historyData['order_status_id'] = $order->getOrderStatus()->getId();
}
//payment status changed?
if ($eventArgs->hasChangedField('paymentStatus')) {
$historyData['previous_payment_status_id'] = $eventArgs->getOldValue('paymentStatus')->getId();
$historyData['payment_status_id'] = $eventArgs->getNewValue('paymentStatus')->getId();
} else {
$historyData['previous_payment_status_id'] = $order->getPaymentStatus()->getId();
$historyData['payment_status_id'] = $order->getPaymentStatus()->getId();
}
$eventArgs->getEntityManager()->getConnection()->insert('s_order_history', $historyData);
}
}
示例2: preUpdate
/**
* @param PreUpdateEventArgs $args
*/
public function preUpdate(PreUpdateEventArgs $args)
{
if (!$args->getEntity() instanceof User || !$args->hasChangedField('email')) {
return;
}
$args->getEntity()->setGoogleId(null);
}
示例3: preUpdate
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
if ($eventArgs->getEntity() instanceof Badge) {
if ($eventArgs->hasChangedField('remis') && $eventArgs->getNewValue('remis') == false) {
$date = new \DateTime('now');
$eventArgs->getEntity()->setDateRendu($date);
}
}
}
示例4: preUpdate
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
if ($eventArgs->getEntity() instanceof Tenue) {
if ($eventArgs->hasChangedField('nombre_rendu')) {
$date = new \DateTime('now');
$eventArgs->getEntity()->setDateRendu($date);
}
}
}
示例5: preUpdate
/**
* Pre update event process
*
* @param LifecycleEventArgs $args
* @return $this
*/
public function preUpdate(PreUpdateEventArgs $args)
{
$entityClass = ClassUtils::getClass($args->getEntity());
if (array_key_exists($entityClass, $this->notificationRules)) {
$rules = $this->notificationRules[$entityClass];
$event = new PreUpdateNotificationEvent($args->getEntity(), $args->getEntityChangeSet(), array('em' => $args->getEntityManager(), 'rules' => $rules));
$this->eventDispatcher->dispatch('numerique1.notification.event.entity_pre_update', $event);
}
return $this;
}
示例6: preUpdate
/**
* @param PreUpdateEventArgs $eventArgs
*/
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if ($this->prepareMedia($entity)) {
// Hack ? Don't know, that's the behaviour Doctrine 2 seems to want
// See : http://www.doctrine-project.org/jira/browse/DDC-1020
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
$uow->recomputeSingleEntityChangeSet($em->getClassMetadata(ClassLookup::getClass($entity)), $eventArgs->getEntity());
}
}
示例7: preUpdate
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
if ($eventArgs->getEntity() instanceof Registration) {
if ($eventArgs->hasChangedField('status') && $eventArgs->getNewValue('status') == 'paid') {
$registration = $eventArgs->getEntity();
$user = $registration->getUser();
$systemMailer = $this->container->get('system_mailer');
$systemMailer->send('App:paid_registration', ['user' => $user, 'registration' => $registration], 'es');
}
}
}
示例8: preUpdate
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if ($entity instanceof StampEntityInterface) {
$entity->setModified(new \DateTime());
}
}
示例9: preUpdate
public function preUpdate(PreUpdateEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof ContainerAwareInterface) {
$entity->setContainer($this->container);
}
}
示例10: preUpdate
/**
* @param PreUpdateEventArgs $event
*/
public function preUpdate(PreUpdateEventArgs $event)
{
$entity = $event->getEntity();
if ($entity instanceof CalendarEvent) {
if ($event->hasChangedField('start') || $event->hasChangedField('reminder')) {
$needChangeSetsComputing = false;
if ($event->hasChangedField('reminder')) {
if ($event->getNewValue('reminder')) {
$start = $event->hasChangedField('start') ? $event->getNewValue('start') : $entity->getStart();
$entity->setRemindAt($this->remindTimeCalculator->calculateRemindAt($start));
} else {
$entity->setRemindAt(null);
}
if ($entity->getReminded()) {
$entity->setReminded(false);
}
$needChangeSetsComputing = true;
} else {
if ($entity->getReminder()) {
$entity->setRemindAt($this->remindTimeCalculator->calculateRemindAt($event->getNewValue('start')));
$needChangeSetsComputing = true;
}
if ($entity->getReminded()) {
$entity->setReminded(false);
$needChangeSetsComputing = true;
}
}
if ($needChangeSetsComputing) {
$em = $event->getEntityManager();
$uow = $em->getUnitOfWork();
$uow->recomputeSingleEntityChangeSet($em->getClassMetadata('OroCalendarBundle:CalendarEvent'), $entity);
}
}
}
}
示例11: preUpdate
/**
* Before an update we check that the product categories are right.
*
* @param PreUpdateEventArgs $event The pre update event.
*/
public function preUpdate(PreUpdateEventArgs $event)
{
$entity = $event->getEntity();
if ($entity instanceof ProductInterface) {
$this->categoryIntegrityFixer->fixProduct($entity);
}
}
示例12: preUpdate
/**
* Before an update we check that the product categories are right.
*
* @param PreUpdateEventArgs $event The pre update event.
*/
public function preUpdate(PreUpdateEventArgs $event)
{
$entity = $event->getEntity();
if ($entity instanceof CategorizableInterface) {
$this->categoryIntegrityFixer->fixCategoriesIntegrity($entity);
}
}
示例13: preUpdate
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if (!$entity instanceof User) {
return;
}
$this->encodePassword($entity);
}
示例14: preUpdate
/**
* @param PreUpdateEventArgs $event
*/
public function preUpdate(PreUpdateEventArgs $event)
{
$entity = $event->getEntity();
// if subtotal or status has been changed
if ($this->isOrderValid($entity) && array_intersect(['subtotalAmount', 'discountAmount', 'status'], array_keys($event->getEntityChangeSet()))) {
$this->ordersForUpdate[$entity->getId()] = true;
}
}
示例15: preUpdate
public function preUpdate(PreUpdateEventArgs $event)
{
$file = $event->getEntity();
if (!$file instanceof File) {
return;
}
$this->updateFile($file);
}