public function PreUpdate(LifecycleEventArgs $args) { if ($args->getEntity() instanceof Rubrica) { if ($args->hasChangedField('cellulare')) { $args->setNewValue('cellulare', '3'); } } }
private function unsetHomepage(LifecycleEventArgs $args) { $entity = $args->getEntity(); $entityManager = $args->getEntityManager(); if ($entity instanceof Page) { // Ist Update oder neuer Eintrag? if ($args instanceof PreUpdateEventArgs && $args->hasChangedField('isHomepage') && $entity->getIsHomepage()) { $entityManager->getRepository('AppBundle:Page')->unsetHomepage($entity); } } }
public function preUpdate(LifecycleEventArgs $args) { $entity = $args->getEntity(); if (!$entity instanceof Publishable) { return; } if (!$args->hasChangedField('status')) { return; } $old = $args->getOldValue('status'); $new = $args->getNewValue('status'); if ($old == Chalk::STATUS_DRAFT) { if ($new == Chalk::STATUS_PUBLISHED) { if (!isset($entity->publishDate)) { $entity->publishDate = new Carbon(); } } else { if ($new == Chalk::STATUS_ARCHIVED) { if (!isset($entity->publishDate)) { $entity->publishDate = new Carbon(); } if (!isset($entity->archiveDate)) { $entity->archiveDate = new Carbon(); } } } } else { if ($old == Chalk::STATUS_PUBLISHED) { if ($new == Chalk::STATUS_ARCHIVED) { if (!isset($entity->archiveDate)) { $entity->archiveDate = new Carbon(); } } } else { if ($old == Chalk::STATUS_ARCHIVED) { $entity->archiveDate = null; } } } }
public function checkNumber(LifecycleEventArgs $args) { // compute the number of invoice if (!$this->number && $this->status != self::DRAFT || $args instanceof PreUpdateEventArgs && $args->hasChangedField('series') && $this->status != self::DRAFT) { $this->setNumber($args->getEntityManager()->getRepository('SiwappInvoiceBundle:Invoice')->getNextNumber($this->getSeries())); } }