예제 #1
0
 /**
  * Load translatable.
  *
  * @param LifecycleEventArgs $args
  */
 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if (!$entity instanceof JobInterface || null === ($translatableClass = $entity->getTranslatableClass())) {
         return;
     }
     $translatable = $args->getObjectManager()->getRepository($translatableClass)->find($entity->getTranslatableId());
     $entity->setTranslatable($translatable);
 }
 /**
  * @param \Doctrine\ORM\Event\LifecycleEventArgs $args
  */
 public function postUpdate(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     $em = $args->getObjectManager();
     if ($entity instanceof VersionableInterface) {
         if (!$entity->hasListener()) {
             $this->makeSnapshot($entity, $em);
         }
     }
 }
예제 #3
0
 public function postPersist(LifecycleEventArgs $args)
 {
     $entity = $args->getObject();
     $entityManager = $args->getObjectManager();
     if ($entity instanceof Article) {
         NumeratorHelper::numerateArticle($entity, $entityManager);
     } else {
         if ($entity instanceof Issue) {
             NumeratorHelper::numerateIssue($entity, $entityManager);
         }
     }
 }
 function let(Reader $reader, LdapManager $ldap, LifecycleEventArgs $eventArgs, ObjectManager $om, ClassMetadata $metadata, LdapObjectSchemaFactory $schemaFactory, LdapConnectionInterface $connection, LdapObjectSchema $schema, LdapQueryBuilder $qb, LdapQuery $query, $entity)
 {
     $rc = new \ReflectionClass('Doctrine\\Common\\Persistence\\Event\\LifecycleEventArgs');
     if ($rc->hasMethod('getObjectManager')) {
         $eventArgs->getObjectManager()->willReturn($om);
         $eventArgs->getObject()->willReturn($entity);
     } else {
         $eventArgs->getEntityManager()->willReturn($om);
         $eventArgs->getEntity()->willReturn($entity);
     }
     $om->getClassMetadata(Argument::any())->willReturn($metadata);
     $this->config = new DomainConfiguration('foo.bar');
     $connection->getConfig()->willReturn($this->config);
     $ldap->getDomainContext()->willReturn('foo.bar');
     $ldap->getSchemaFactory()->willReturn($schemaFactory);
     $ldap->getConnection()->willReturn($connection);
     $ldap->buildLdapQuery()->willReturn($qb);
     $qb->getLdapQuery()->willReturn($query);
     $this->beConstructedWith($reader, $ldap);
 }
 /**
  * @param LifecycleEventArgs $args
  */
 public function postLoad(LifecycleEventArgs $args)
 {
     $layoutBlock = $args->getEntity();
     if ($layoutBlock instanceof LayoutBlock) {
         if ($layoutBlock->getClassType() || $layoutBlock->getObjectId()) {
             /** @var EntityManager $em */
             $em = $args->getObjectManager();
             if ($layoutBlock->getObjectId()) {
                 /** @var ContentInterface $content */
                 $content = $em->getRepository($layoutBlock->getClassType())->find($layoutBlock->getObjectId());
                 if ($content) {
                     $layoutBlock->setContent($content);
                 }
             } else {
                 $em->remove($layoutBlock);
                 $em->flush($layoutBlock);
             }
         }
     }
 }
예제 #6
0
 public function postPersist(LifecycleEventArgs $args)
 {
     if (!$args->getObject() instanceof Payment) {
         return;
     }
     /** @var Payment $entity */
     $entity = $args->getObject();
     $entityManager = $args->getObjectManager();
     $mail = $entityManager->getRepository("BdEMainBundle:Mail")->getMail($entity->getStudent(), $entity->getProduct());
     if ($mail) {
         $mailgun = $this->containerInterface->get("bde.mailgun");
         $mailer = $this->containerInterface->get("bde.main.mailer_service");
         $mail_data = $mailer->generateMailFromData($mail, $entity->getStudent());
         $mb = $mailgun->MessageBuilder();
         $mb->setSubject($mail_data['subject']);
         $mb->setHtmlBody($mail_data['body']);
         $mb->setFromAddress($entityManager->getRepository("BdEMainBundle:Config")->get("bde.mail.sender", "OrgaIf BdE <*****@*****.**>"));
         $mb->addToRecipient($entity->getStudent()->getMail());
         $mailgun->sendMessage($entityManager->getRepository("BdEMainBundle:Config")->get("mailgun.domain", "mail.vienne.me"), $mb->getMessage());
     }
 }
예제 #7
0
 /**
  * @ORM\PrePersist()
  */
 public function prePersist(LifecycleEventArgs $event)
 {
     $this->dealWithAtLeastOneTranslation($event->getObjectManager());
 }
예제 #8
0
 /**
  * Handles postUpdate event triggered by doctrine.
  *
  * @param \Doctrine\ORM\Event\LifecycleEventArgs $args The lifecycle event arguments
  */
 public function postUpdate(LifecycleEventArgs $args)
 {
     $this->handleEvent('postUpdate', $args->getObject(), $args->getObjectManager());
 }
 function it_handles_post_update(NotifiableEventRegistryInterface $notifiableEventRegistry, NotifierRegistryInterface $notifierRegistry, NotifiableEventInterface $notifiableEvent, NotifierInterface $notifier, NotificationInterface $notification, EntityManager $manager, LifecycleEventArgs $args)
 {
     $object = new stdClass();
     $this->handleEventConfig('postUpdate', $object, $notifiableEventRegistry, $notifierRegistry, $notifiableEvent, $notifier, $notification);
     $args->getObject()->willReturn(new stdClass());
     $args->getObjectManager()->willReturn($manager);
     $this->postUpdate($args);
 }
 /**
  * Avoid calling deprecated methods if possible.
  *
  * @param LifecycleEventArgs $args
  * @return \Doctrine\Common\Persistence\ObjectManager|\Doctrine\ORM\EntityManager
  */
 protected function getOmFromLifeCycleArgs(LifecycleEventArgs $args)
 {
     $rc = new \ReflectionClass('Doctrine\\Common\\Persistence\\Event\\LifecycleEventArgs');
     if ($rc->hasMethod('getObjectManager')) {
         return $args->getObjectManager();
     } else {
         return $args->getEntityManager();
     }
 }
 /**
  * @param $entity
  * @param ORM\Event\LifecycleEventArgs $eventArgs
  *
  * @throws Phone\Exceptions\NoValidCountryException
  * @throws Phone\Exceptions\NoValidPhoneException
  */
 public function postLoad($entity, ORM\Event\LifecycleEventArgs $eventArgs)
 {
     $this->postLoadAndPreFlush($entity, $eventArgs->getObjectManager());
 }