public function add(EntityInterface $entity)
    {
        if (!is_a($entity, $this->getEntityClass())) {
            throw new Exception('The given entity (' . get_class($entity) . ') is not compatible with this data source (' . self::class . '.');
        }
        
        try {
            $em = $this->entityManager->getDoctrineEntityManager();
            $em->persist($entity);
            $em->flush();
            
            return $entity->getId();
        } catch (\Exception $e) {
            throw new Exception('Cannot add the entity "' . $entity . '".', 0, $e);
        }
    }
public function add(EntityInterface $entity)
    {
        if (!is_a($entity, $this->getEntityClass())) {
            throw new Exception('The given entity (' . get_class($entity) . ') is not compatible with this data source (' . self::class . '.');
        }
        
        try {
            $em = $this->entityManager->getDoctrineEntityManager();
            $em->persist($entity);
            $em->flush();
            
            return $entity->getId();
        } catch (\Exception $e) {
            throw new Exception('Cannot add the entity "' . $entity . '".', 0, $e);
        }
    }
public function add ( EntityInterface $ entity ) { if ( ! is_a ( $ entity , $ this -> getEntityClass ( ) ) ) { throw new Exception ( 'The given entity (' . get_class ( $ entity ) . ') is not compatible with this data source (' . self :: class . '.' ) ; } try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ em -> persist ( $ entity ) ; $ em -> flush ( ) ; return $ entity -> getId ( ) ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot add the entity "' . $ entity . '".' , 0 , $ e ) ; } }
Adds an entity. Returns the id of the entity
or false, if the entity can not inserted.

@param \Zepi\DataSource\Core\Entity\EntityInterface $entity
@return \Zepi\DataSource\Core\Entity\EntityInterface|false

@throws \Zepi\DataSource\Doctrine\Exception The given entity is not compatible with this data source.
@throws \Zepi\DataSource\Doctrine\Exception Cannot add the entity "{entity}".
Adds an entity . Returns the id of the entity or false if the entity can not inserted .