本文整理汇总了PHP中Doctrine\ORM\Event\PreUpdateEventArgs::hasChangedField方法的典型用法代码示例。如果您正苦于以下问题:PHP PreUpdateEventArgs::hasChangedField方法的具体用法?PHP PreUpdateEventArgs::hasChangedField怎么用?PHP PreUpdateEventArgs::hasChangedField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Event\PreUpdateEventArgs
的用法示例。
在下文中一共展示了PreUpdateEventArgs::hasChangedField方法的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 $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);
}
}
}
}
示例3: preUpdate
public function preUpdate(PreUpdateEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof $this->orderProductClass) {
$price = $entity->getPrice();
if ($args->hasChangedField('quantity') || $args->hasChangedField('product')) {
$price = $entity->getQuantity() * $entity->getProduct()->getPrice();
}
$entity->setPrice($price);
$entity->setUpdatedAt(new \DateTime());
}
}
示例4: markAsModified
private function markAsModified(PreUpdateEventArgs $args)
{
$entity = $args->getEntity();
$securityToken = $this->securityContext->getToken();
if (!$entity instanceof Advertisement || null == $securityToken) {
return;
}
$user = $securityToken->getUser();
if (($args->hasChangedField('description') || $args->hasChangedField('title')) && $user instanceof Advertiser && $user->getId() == $entity->getAdvertiser()->getId()) {
$entity->markAsModified();
$args->getEntityManager()->getUnitOfWork()->computeChangeSet($args->getEntityManager()->getClassMetadata(get_class($entity)), $entity);
}
}
示例5: preUpdate
/**
* @ORM\PreUpdate
*/
public function preUpdate($item, PreUpdateEventArgs $event)
{
if ($item->getLevel() > 0) {
$item->setRootSequence(NULL);
} elseif ($event->hasChangedField('parent') && is_null($event->getNewValue('parent')) && !is_null($event->getOldValue('parent'))) {
$this->setMaxRootSequence($item, $event);
} else {
if (!$event->hasChangedField('rootSequence')) {
return;
}
$oldSequence = $event->getOldValue('rootSequence');
$newSequence = $event->getNewValue('rootSequence');
if ($oldSequence === $newSequence) {
return;
}
$em = $event->getEntityManager();
$qb = $em->createQueryBuilder();
$qb->update(get_class($item), 'i')->where('i.rootSequence = ' . $newSequence);
if ($newSequence > $oldSequence) {
$qb->set('i.rootSequence', 'i.rootSequence - 1');
} elseif ($newSequence < $oldSequence) {
$qb->set('i.rootSequence', 'i.rootSequence + 1');
}
$qb->getQuery()->execute();
}
}
示例6: preUpdate
public function preUpdate(User $user, PreUpdateEventArgs $event)
{
if ($event->hasChangedField('email')) {
$token = $this->tokenGenerator->generateEmailConfirmationToken($user);
$this->emailDispatcher->sendEmailVerifyEmail($user, $token);
}
}
示例7: preUpdate
/**
* @param PreUpdateEventArgs $args
*/
public function preUpdate(PreUpdateEventArgs $args)
{
if (!$args->getEntity() instanceof User || !$args->hasChangedField('email')) {
return;
}
$args->getEntity()->setGoogleId(null);
}
示例8: getChangesets
private function getChangesets(PreUpdateEventArgs $args)
{
$oldValues = array();
$newValues = array();
$fields = array('avatar' => 'Фото', 'firstName' => 'Имя', 'lastName' => 'Фамилия', 'surName' => 'Отчество', 'birthdate' => 'Дата рождения', 'hideBirthdate' => 'Скрывать дату рождения', 'city' => 'Город', 'address' => 'Адрес', 'university' => 'ВУЗ', 'graduateYear' => 'Год окончания ВУЗа', 'primarySpecialty' => 'Основная специальность', 'secondarySpecialty' => 'Второстепенная специальность', 'specialization' => 'Специализация', 'academicTitle' => 'Звание', 'jobType' => 'Место работы', 'job' => 'Название организации', 'jobAlignment' => 'Место организации', 'phone' => 'Телефон', 'position' => 'Должность', 'diploma' => 'Диплом ВУЗа', 'achievements' => 'О себе', 'academicDegree' => 'Ученая степень', 'dissertation' => 'Тема диссертации', 'diplomaScientic' => 'Диплом ученой степени', 'digestSubscribed' => 'Подписка на дайджест', 'commentSubscribed' => 'Подписка ответов на комментарии');
foreach ($fields as $field => $label) {
if ($args->hasChangedField($field)) {
$old = $args->getOldValue($field);
$new = $args->getNewValue($field);
if ($old == $new || is_array($old) && empty($new)) {
continue;
}
if ($new instanceof UploadedFile) {
$this->imgFields[$field] = $label;
$oldValues[] = "<b>{$label}:</b> ~";
} else {
$oldValues[] = "<b>{$label}:</b> " . ($old instanceof \DateTime ? $old->format('d.m.Y') : $old);
$newValues[] = "<b>{$label}:</b> " . ($new instanceof \DateTime ? $new->format('d.m.Y') : $new);
}
}
}
if (count($oldValues)) {
$oldValues = implode('<br/>', $oldValues);
$newValues = implode('<br/>', $newValues);
return array($oldValues, $newValues);
}
return array(null, null);
}
示例9: preUpdate
/**
* Maj des scripts du serveur si la config du serveur (port, maxplayers, dir) a été modifié
* Ou si la config du jeu (bin, binDir, launchName, map, orangebox, source) a été modifié
* Ou si l'IP publique de la machine a été modifié
*
* Réinstallation du serveur
* Si des modifs ont été faites sur la machine (IP privée, home, user)
* Ou si le serveur de jeu n'est plus sur la meme machine
* Ou si le jeu du serveur est modifié
*
* @param \Doctrine\ORM\Event\PreUpdateEventArgs $args
*/
public function preUpdate(PreUpdateEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof SteamServer) {
if ($args->hasChangedField('port') || $args->hasChangedField('maxplayers') && $entity->getGame()->getLaunchName() != "csgo" || $args->hasChangedField('core') || $args->hasChangedField('mode')) {
try {
$entity->uploadHldsScript($this->getTwig());
} catch (\Exception $e) {
}
}
if ($args->hasChangedField('maxplayers') && $entity->getGame()->getLaunchName() == "csgo") {
try {
$entity->modifyGameModesCfg();
} catch (\Exception $e) {
}
}
if ($args->hasChangedField('dir')) {
try {
$entity->uploadShellScripts($this->getTwig());
} catch (\Exception $e) {
}
}
if ($args->hasChangedField('rebootAt')) {
//suppression del'ancienne tâche cron
$entity->removeAutoReboot($args->getOldValue('rebootAt'));
if ($args->getNewValue('rebootAt') != null) {
$entity->addAutoReboot();
}
}
if ($args->hasChangedField('name') || $args->hasChangedField('rconPassword')) {
try {
$entity->modifyServerCfgFile();
} catch (\Exception $e) {
}
}
} elseif ($entity instanceof Machine) {
// Upload des scripts si l'IP publique ou le home de la machine a été modifié
if ($args->hasChangedField('publicIp') || $args->hasChangedField('home')) {
$servers = $entity->getGameServers();
foreach ($servers as $server) {
if (!$server instanceof SteamServer) {
continue;
}
try {
$server->uploadShellScripts($this->getTwig());
} catch (\Exception $e) {
}
}
}
}
}
示例10: preUpdate
/**
* sets the modification date
*/
public function preUpdate(Domains $domain, PreUpdateEventArgs $event)
{
$domain->setModified(new \DateTime());
if ($event->hasChangedField('name')) {
$domain->setNeedsSoaUpdate(true);
}
return true;
}
示例11: preUpdate
/**
* Delete old avatar image from disk if it has been changed
*
* @param User $user
* @param PreUpdateEventArgs $event
*/
public function preUpdate(User $user, PreUpdateEventArgs $event)
{
if ($event->hasChangedField('avatarImage')) {
$oldAvatarImage = $event->getOldValue('avatarImage');
if (!empty($oldAvatarImage)) {
$this->userService->deleteAvatar($oldAvatarImage);
}
}
}
示例12: preUpdate
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
if ($eventArgs->getEntity() instanceof Tenue) {
if ($eventArgs->hasChangedField('nombre_rendu')) {
$date = new \DateTime('now');
$eventArgs->getEntity()->setDateRendu($date);
}
}
}
示例13: 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);
}
}
}
示例14: preUpdate
public function preUpdate(PreUpdateEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof Issue) {
if ($args->hasChangedField('assignee')) {
$entity->addCollaborator($entity->getAssignee());
}
}
}
示例15: preUpdate
/** @ORM\PreUpdate */
public function preUpdate(Company $company, PreUpdateEventArgs $event)
{
$entity = $event->getEntity();
$entityManager = $event->getEntityManager();
if ($event->hasChangedField('identification')) {
$status = $entityManager->getRepository('MainCommonBundle:Status\\PhotographerStatus')->findOneById(1);
//To verify
$company->setStatus($status);
}
}