當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。