本文整理匯總了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)
}
}
}