public function postLoad(LifecycleEventArgs $eventArgs)
 {
     $entity = $eventArgs->getEntity();
     $metadata = $this->getMetadata();
     if (!$metadata->hasEntityMetadata($entity)) {
         return;
     }
     $this->service->loadVocabularyFields($entity);
 }
Esempio n. 2
0
 /**
  *
  * Loads the appropriate entity object given the entity-type and identifier in an EntityTerm object.
  *
  * @param LifecycleEventArgs $eventArgs
  */
 public function postLoad(LifecycleEventArgs $eventArgs)
 {
     $entityTerm = $eventArgs->getEntity();
     if ($entityTerm instanceof EntityTerm) {
         $metadata = $this->service->getMetadata()->getEntityMetadata($entityTerm->getEntityType());
         $entity = $eventArgs->getEntityManager()->find($metadata->getReflectionClass()->getName(), $entityTerm->getEntityIdentifier());
         if ($entity) {
             $entityTerm->setEntity($entity);
         }
     }
 }
Esempio n. 3
0
 public function prePersist(LifecycleEventArgs $eventArgs)
 {
     $entity = $eventArgs->getEntity();
     if (!$entity instanceof EntityTerm) {
         return;
     }
     $relEntity = $entity->getEntity();
     $metadata = $this->service->getMetadata()->getEntityMetadata($relEntity);
     $id = $metadata->extractIdentifier($relEntity);
     $entity->setEntityIdentifier($id);
     $entity->setEntityType($metadata->getType());
 }
Esempio n. 4
0
 public function preRemove(LifecycleEventArgs $eventArgs)
 {
     $entity = $eventArgs->getEntity();
     if (!$this->service->getMetadata()->hasEntityMetadata($entity)) {
         return;
     }
     $metadata = $this->service->getMetadata()->getEntityMetadata($entity);
     $type = $metadata->getType();
     $id = $metadata->extractIdentifier($entity);
     $dql = $eventArgs->getEntityManager()->createQueryBuilder()->delete('ALTaxonomyBundle:EntityTerm', 'et')->andWhere('et.entityType = :type')->andWhere('et.entityIdentifier = :id')->setParameters(array('type' => $type, 'id' => $id));
     $dql->getQuery()->execute();
 }