本文整理汇总了PHP中Doctrine\ORM\Event\PreUpdateEventArgs类的典型用法代码示例。如果您正苦于以下问题:PHP PreUpdateEventArgs类的具体用法?PHP PreUpdateEventArgs怎么用?PHP PreUpdateEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PreUpdateEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preUpdate
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if ($entity instanceof StampEntityInterface) {
$entity->setModified(new \DateTime());
}
}
示例2: 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);
}
}
示例3: preUpdate
public function preUpdate(User $user, PreUpdateEventArgs $event)
{
if ($event->hasChangedField('email')) {
$token = $this->tokenGenerator->generateEmailConfirmationToken($user);
$this->emailDispatcher->sendEmailVerifyEmail($user, $token);
}
}
示例4: 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);
}
示例5: preUpdate
/**
* @param PreUpdateEventArgs $args
*/
public function preUpdate(PreUpdateEventArgs $args)
{
if (!$args->getEntity() instanceof User || !$args->hasChangedField('email')) {
return;
}
$args->getEntity()->setGoogleId(null);
}
示例6: preUpdate
/**
* @ORM\PreUpdate
*/
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
if (!$this->isEdited) {
$this->isEdited = true;
$this->backupTime = $eventArgs->getOldValue('time');
}
}
示例7: 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();
}
}
示例8: 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);
}
}
示例9: preUpdate
public function preUpdate(PreUpdateEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof ContainerAwareInterface) {
$entity->setContainer($this->container);
}
}
示例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
public function preUpdate(PreUpdateEventArgs $event)
{
$file = $event->getEntity();
if (!$file instanceof File) {
return;
}
$this->updateFile($file);
}
示例12: preUpdate
/**
* Pre update event listener.
*
* @param PreUpdateEventArgs $eventArgs The pre update event args.
*
* @return $this Self object
*/
public function preUpdate(PreUpdateEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if ($entity instanceof CategoryInterface) {
$this->removeParentCategoryForRootCategory($entity);
}
return $this;
}
示例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
/**
* Cleans the facebbok username.
*
* @param PreUpdateEventArgs $args
*/
public function preUpdate(PreUpdateEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof Plugin && $entity->getNamespace() == 'Elcodi\\Plugin\\TwitterBundle\\ElcodiTwitterBundle') {
$twitterAccount = $entity->getConfiguration()->getFieldValue('twitter_account');
$entity->getConfiguration()->setFieldValue('twitter_account', $this->twitterUsernameCleaner->clean($twitterAccount));
}
}