本文整理汇总了PHP中Doctrine\ORM\Event\LifecycleEventArgs::getObject方法的典型用法代码示例。如果您正苦于以下问题:PHP LifecycleEventArgs::getObject方法的具体用法?PHP LifecycleEventArgs::getObject怎么用?PHP LifecycleEventArgs::getObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Event\LifecycleEventArgs
的用法示例。
在下文中一共展示了LifecycleEventArgs::getObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postRemove
/**
* @param LifecycleEventArgs $event The event.
*/
public function postRemove(LifecycleEventArgs $event)
{
if ($event->getObject() instanceof ResourceObjectInterface) {
/** @var ResourceObjectInterface $resource */
$resource = $event->getObject();
if ($resource->getLocation() && $resource->getMapping()) {
$resolverName = $this->getLocationConfig('resolver', $resource->getLocation(), $this->config);
$resolver = $this->resolverManager->get($resolverName);
$resolver->setConfig($this->config);
$this->loadResource($resource);
$this->remove($resource, $resolver);
}
}
}
示例2: postLoad
/**
* Inject Translator locale into loaded object.
*
* @param LifecycleEventArgs $args
*/
public function postLoad(LifecycleEventArgs $args)
{
$object = $args->getObject();
if ($object instanceof LocaleAware) {
$object->setCurrentLocale($this->translator->getLocale());
}
}
示例3: postLoad
public function postLoad(LifecycleEventArgs $args)
{
$entity = $args->getObject();
if ($entity instanceof ServiceAwareEntityInterface) {
$entity->setServiceLocator($this->serviceManager);
}
}
示例4: postLoad
/**
* Post load
*
* @param LifecycleEventArgs $args
*/
public function postLoad(LifecycleEventArgs $args)
{
$entity = $args->getObject();
if ($entity instanceof DocumentNode) {
$entity->setUserNode($this->nodeProvider->isUserNode($entity));
}
}
示例5: postLoad
/**
* @param LifecycleEventArgs $event The event.
*/
public function postLoad(LifecycleEventArgs $event)
{
$object = $event->getObject();
if ($object instanceof ProxyServiceInterface && $object->getServiceName()) {
$object->setService($this->container->get($object->getServiceName()));
}
}
示例6: preUpdate
/**
* @param LifecycleEventArgs $event The event.
*/
public function preUpdate(LifecycleEventArgs $event)
{
$object = $event->getObject();
if ($object instanceof TimestampableInterface) {
$object->setUpdatedAt(new \DateTime());
}
}
示例7: preRemove
public function preRemove(LifecycleEventArgs $event)
{
$object = $event->getObject();
if ($this->isReferenceable($object)) {
$this->objectAdapterManager->removeReference($object);
}
}
示例8: postLoad
/**
* @param LifecycleEventArgs $event
*/
public function postLoad(LifecycleEventArgs $event)
{
$settings = $event->getObject();
if ($settings instanceof SettingsInterface) {
$this->reverseTransform($settings);
}
}
示例9: prePersist
public function prePersist(LifecycleEventArgs $args)
{
$object = $args->getObject();
if ($object instanceof UserInterface) {
$this->updatePassword($object);
}
}
示例10: postRemove
/**
* @param LifecycleEventArgs $args
*/
public function postRemove(LifecycleEventArgs $args)
{
$entity = $args->getObject();
$em = $args->getEntityManager();
$meta = $em->getClassMetadata(get_class($entity));
$this->logEntityChange('removed', $meta, $entity);
}
示例11: preUpdate
public function preUpdate(LifecycleEventArgs $args)
{
$entity = $args->getObject();
if ($entity instanceof PlaceAddress) {
$this->insertTranslation($entity);
}
}
示例12: prePersist
public function prePersist(LifecycleEventArgs $event)
{
$object = $event->getObject();
if ($object instanceof UuidAwareInterface and !$object->getId()) {
$object->setId((new UuidGenerator())->generate($event->getEntityManager(), $object));
}
}
示例13: preRemove
public function preRemove(LifecycleEventArgs $event)
{
$objectAdapterManager = $this->container->get('doctrine_orm_phpcr_adapter.adapter.default_adapter_manager');
$object = $event->getObject();
if ($this->isReferenceable($object, $objectAdapterManager)) {
$objectAdapterManager->removeReference($object);
}
}
示例14: postUpdate
public function postUpdate(LifecycleEventArgs $event)
{
$object = $event->getObject();
if ($object instanceof User && $object->isEmailChanged()) {
$this->container->get('stats_system')->postRequest($object);
$this->container->get('marketing_system')->postRequest($object);
$this->container->get('logger')->info("New email for user with id {$object->getId()}: {$object->getEmail()}");
}
}
示例15: preUpdate
/**
* sets Traceable dateTime and user information when updating entity
*
* @param LifecycleEventArgs $eventArgs
*/
public function preUpdate(LifecycleEventArgs $eventArgs)
{
$entity = $eventArgs->getObject();
if (!$this->hasTrait($entity, 'Librinfo\\DoctrineBundle\\Entity\\Traits\\Traceable')) {
return;
}
$this->logger->debug("[TraceableListener] Entering TraceableListener for « preUpdate » event");
$now = new DateTime('NOW');
$entity->setUpdatedAt($now);
}