本文整理汇总了PHP中Doctrine\ORM\Event\LifecycleEventArgs::getObjectManager方法的典型用法代码示例。如果您正苦于以下问题:PHP LifecycleEventArgs::getObjectManager方法的具体用法?PHP LifecycleEventArgs::getObjectManager怎么用?PHP LifecycleEventArgs::getObjectManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Event\LifecycleEventArgs
的用法示例。
在下文中一共展示了LifecycleEventArgs::getObjectManager方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postLoad
/**
* 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);
}
示例2: postUpdate
/**
* @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: postPersist
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);
}
}
}
示例4: let
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);
}
示例5: postLoad
/**
* @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: postPersist
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 <bde.if@insa-lyon.fr>"));
$mb->addToRecipient($entity->getStudent()->getMail());
$mailgun->sendMessage($entityManager->getRepository("BdEMainBundle:Config")->get("mailgun.domain", "mail.vienne.me"), $mb->getMessage());
}
}
示例7: prePersist
/**
* @ORM\PrePersist()
*/
public function prePersist(LifecycleEventArgs $event)
{
$this->dealWithAtLeastOneTranslation($event->getObjectManager());
}
示例8: postUpdate
/**
* 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());
}
示例9: stdClass
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);
}
示例10: getOmFromLifeCycleArgs
/**
* 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();
}
}
示例11: postLoad
/**
* @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());
}