本文整理汇总了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);
}
}
示例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);
}
示例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)
}
}
}