public function prePersist(LifecycleEventArgs $args)
    {
        $entity        = $args->getEntity();
        $entityManager = $args->getEntityManager();

        $classMetadata = $entityManager->getClassMetadata(get_class($entity));

        if (false == $this->isModular($classMetadata)) {
            return;
        }

        if (null === $entity->getModule() && null !== $this->getModuleManager()->getCurrentModule()) {
            $entity->setModule($this->getModuleManager()->getCurrentModule());
        }
    }
public function prePersist(LifecycleEventArgs $args)
    {
        $entity        = $args->getEntity();
        $entityManager = $args->getEntityManager();

        $classMetadata = $entityManager->getClassMetadata(get_class($entity));

        if (false == $this->isModular($classMetadata)) {
            return;
        }

        if (null === $entity->getModule() && null !== $this->getModuleManager()->getCurrentModule()) {
            $entity->setModule($this->getModuleManager()->getCurrentModule());
        }
    }
public function prePersist ( LifecycleEventArgs $ args ) { $ entity = $ args -> getEntity ( ) ; $ entityManager = $ args -> getEntityManager ( ) ; $ classMetadata = $ entityManager -> getClassMetadata ( get_class ( $ entity ) ) ; if ( false == $ this -> isModular ( $ classMetadata ) ) { return ; } if ( null === $ entity -> getModule ( ) && null !== $ this -> getModuleManager ( ) -> getCurrentModule ( ) ) { $ entity -> setModule ( $ this -> getModuleManager ( ) -> getCurrentModule ( ) ) ; } }
Handles actions before creation of an entity.

Sets the module of an entity to the current module defined
by the module manager if it has been left empty.

@param LifecycleEventArgs $args
Handles actions before creation of an entity .