当前位置: 首页>>代码示例>>PHP>>正文


PHP LifecycleEventArgs::getObject方法代码示例

本文整理汇总了PHP中Doctrine\ODM\MongoDB\Event\LifecycleEventArgs::getObject方法的典型用法代码示例。如果您正苦于以下问题:PHP LifecycleEventArgs::getObject方法的具体用法?PHP LifecycleEventArgs::getObject怎么用?PHP LifecycleEventArgs::getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ODM\MongoDB\Event\LifecycleEventArgs的用法示例。


在下文中一共展示了LifecycleEventArgs::getObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postPersist

 /**
  * post persist callback method
  *
  * @param LifecycleEventArgs $event event args
  *
  * @return void
  */
 public function postPersist(LifecycleEventArgs $event)
 {
     $object = $event->getObject();
     if ($object instanceof Translatable) {
         $event = new TranslatablePersistEvent($object->getLocale(), $object->getDomain());
         $this->dispatcher->dispatch(TranslatablePersistEvent::EVENT_NAME, $event);
     }
 }
开发者ID:alebon,项目名称:graviton,代码行数:15,代码来源:PostPersistTranslatableListener.php

示例2:

 function it_converts_metric_data_before_updating(LifecycleEventArgs $args, MetricInterface $metric, MeasureManager $manager, MeasureConverter $converter, DocumentManager $dm, ProductInterface $product, ProductValueInterface $productValue, UnitOfWork $uow, ClassMetadata $metadata)
 {
     $args->getObject()->willReturn($product);
     $product->getValues()->willReturn([$productValue]);
     $productValue->getData()->willReturn($metric);
     $metric->getId()->willReturn(12);
     $args->getObjectManager()->willReturn($dm);
     $dm->getUnitOfWork()->willReturn($uow);
     $uow->recomputeSingleDocumentChangeSet(Argument::type('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata'), $metric)->shouldBeCalled();
     $metric->getUnit()->willReturn('cm');
     $metric->getFamily()->willReturn('distance');
     $metric->getData()->willReturn(100);
     $manager->getStandardUnitForFamily('distance')->willReturn('m');
     $converter->setFamily('distance')->shouldBeCalled()->willReturn($converter);
     $converter->convertBaseToStandard('cm', 100)->willReturn(1);
     $metric->setBaseData(1)->shouldBeCalled()->willReturn($metric);
     $metric->setBaseUnit('m')->shouldBeCalled();
     $dm->getClassMetadata(Argument::any())->willReturn($metadata);
     $dm->getUnitOfWork()->willReturn($uow);
     $uow->recomputeSingleDocumentChangeSet($metadata, $metric)->shouldBeCalled();
     $this->preUpdate($args);
 }
开发者ID:noglitchyo,项目名称:pim-community-dev,代码行数:22,代码来源:MetricBaseValuesSubscriberSpec.php

示例3: postPersist

 /**
  * post persist callback method
  *
  * @param LifecycleEventArgs $event event args
  *
  * @return void
  */
 public function postPersist(LifecycleEventArgs $event)
 {
     $object = $event->getObject();
     if ($object instanceof Translatable) {
         $domain = $object->getDomain();
         $locale = $object->getLocale();
         $triggerFile = __DIR__ . '/../Resources/translations/' . $domain . '.' . $locale . '.odm';
         $cacheDirMask = __DIR__ . '/../../../../app/cache/*/translations';
         $fs = new Filesystem();
         if (!$fs->exists($triggerFile)) {
             $fs->touch($triggerFile);
         }
         try {
             $finder = new Finder();
             $finder->files()->in($cacheDirMask)->name('*.' . $locale . '.*');
             foreach ($finder as $file) {
                 $fs->remove($file->getRealPath());
             }
         } catch (\InvalidArgumentException $e) {
             // InvalidArgumentException gets thrown if the translation cache dir doesn't exist.
             // we ignore it since it's normal under some circumstances (no cache warmup yet)
         }
     }
 }
开发者ID:smoskalenko,项目名称:graviton,代码行数:31,代码来源:PostPersistTranslatableListener.php


注:本文中的Doctrine\ODM\MongoDB\Event\LifecycleEventArgs::getObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。