@param string $entityFqn

@return EntitySaverInterface
13482
public function getSaverForEntityFqn(string $entityFqn): EntitySaverInterface
    {
        $saverFqn = $this->getSaverFqn($entityFqn);
        if (class_exists($saverFqn)) {
            return new $saverFqn($this->entityManager, $this->namespaceHelper);
        }

        return $this->genericSaver;
    }
196888
private final static function &getInstances($fqcn)
    {
        if (!isset(self::$instances[$fqcn])) {
            self::loadClass($fqcn);
        }

        return self::$instances[$fqcn];
    }
173902
function getRepository($entityName)
    {
        if (isset($this->cachedRepository[$entityName])) {
            return $this->cachedRepository[$entityName];
        }
        $className = "Fredy\\Model\\Repository\\Repository";
        $entityClassName = 'Model\\Entity\\'.$entityName;
        return new $className(new $entityClassName(),$this->db);
    }
684542
private function getNewInstance(string $entityFqn, $id): EntityInterface
    {
        if (isset(self::$created[$entityFqn][(string)$id])) {
            throw new \RuntimeException('Trying to get a new instance when one has already been created for this ID');
        }
        $reflection = $this->getDoctrineStaticMetaForEntityFqn($entityFqn)
                           ->getReflectionClass();
        $entity     = $reflection->newInstanceWithoutConstructor();

        $runInit = $reflection->getMethod(UsesPHPMetaDataInterface::METHOD_RUN_INIT);
        $runInit->setAccessible(true);
        $runInit->invoke($entity);

        $transactionProperty = $reflection->getProperty(AlwaysValidInterface::CREATION_TRANSACTION_RUNNING_PROPERTY);
        $transactionProperty->setAccessible(true);
        $transactionProperty->setValue($entity, true);

        $idSetter = $reflection->getMethod('set' . IdFieldInterface::PROP_ID);
        $idSetter->setAccessible(true);
        $idSetter->invoke($entity, $id);

        if ($entity instanceof EntityInterface) {
            $this->initialiseEntity($entity);

            $this->entityManager->persist($entity);

            return $entity;
        }
        throw new \LogicException('Failed to create an instance of EntityInterface');
    }
1287990
public function save(EntityInterface $entity)
    {
        $entity = $this->beforeSave($entity);

        $this->getEntityManager()->persist($entity);
        $this->getEntityManager()->flush($entity);

        $this->afterSave($entity);
    }
397983
public function insert(EntityInterface $entity)
	{
		$sql = <<<EOT
INSERT INTO `$this->tableName` (`Name`, `Description`, `Created`) 
VALUES ( :name , :description , :created )
EOT;

		$stmt = $this->pdo->prepare($sql);
		$stmt->bindParam(':name', $entity->getName(), \PDO::PARAM_STR);
		$stmt->bindParam(':description', $entity->getDescription(), \PDO::PARAM_STR);
		$stmt->bindParam(':created', $entity->getCreatedRfc3339(), \PDO::PARAM_STR);
		$res = $stmt->execute();

		if ($res === false || $stmt->rowCount() !== 1) {
			return false;
		}

		$entity->setProjectId($this->pdo->lastInsertId());

		return $entity;
	}
95006
public function getTraitsNamespaceForEntity(
        string $entityFqn
    ): string {
        $traitsNamespace = $this->getProjectNamespaceRootFromEntityFqn($entityFqn)
                           . AbstractGenerator::ENTITY_RELATIONS_NAMESPACE
                           . '\\' . $this->getEntitySubNamespace($entityFqn)
                           . '\\Traits';

        return $traitsNamespace;
    }
33024
public function persist(EntityInterface $entity)
    {
        $reflection = $this->getEntityClassReflection();
        
        if ($reflection->isInstance($entity)) {
            
            $this->dispatchEvent(ORMEvents::beforePersist, new EntityLifecycleEvent($this, $entity));
            
            $connection = $this->getConnection();
            $metadata = $this->getEntityMetadata();
            $isEntityNew = $this->isNewEntity($entity);
            $entityData = $this->getEntityDataArray($entity);
            
            $persister = $this->getPersisterForEntity($entity);
            $persister->setDataBatch($entityData);
            
            $propertyIdentifier = $metadata->getName($metadata->getIdentifier(), Metadata::CAMILIZED);
            
            if (!$isEntityNew && $reflection->hasProperty($propertyIdentifier)) {
                $persister->addConditions($metadata->getIdentifier(), $entity->getByProperty($propertyIdentifier));
            }
            
            $connection->start();
            $connection->execute($persister->toSQL());
            
            if ($reflection->hasProperty($propertyIdentifier) && $isEntityNew) {
                $reflection->getProperty($propertyIdentifier)->setValue($entity, $connection->lastInsertId());
            }
            
            $this->dispatchEvent(ORMEvents::afterPersist, new EntityLifecycleEvent($this, $entity));
            
            // commit changes after event dispatching
            $connection->commit();
            
            return $this;
        }
        
        throw new NotSupportedException(sprintf('Unable to persist entity! Actual entity "%s" expected entity "%s"',
            get_class($entity), $this->getEntityName()));
    }
891662
protected function beforeSave(EntityInterface $entity): EntityInterface
    {
        $argv = compact('entity');
        $argv = $this->getEventManager()->prepareArgs($argv);

        $this->getEventManager()->trigger("{$this->event_prefix}_save_before", $this, $argv);
        if ($this->entity_event_prefix) {
            $this->getEventManager()->trigger("{$this->entity_event_prefix}_save_before", $this, $argv);
        }

        return $argv['entity'];
    }
340693
public function createDoctrineDetails(string $entityClassName)
    {
        $metadata = $this->getMetadata($entityClassName);

        if ($metadata instanceof ClassMetadata) {
            return new EntityDetails($metadata);
        }

        return null;
    }
3322
public static function create($conn, Configuration $config = null, EventManager $eventManager = null)
    {
        if (null === $config) {
            $config = new Configuration();
            $config->setProxyDir(__DIR__ . '/../Proxies');
            $config->setProxyNamespace('Doctrine\Tests\Proxies');
            $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([], true));
        }
        if (null === $eventManager) {
            $eventManager = new EventManager();
        }

        return new EntityManagerMock($conn, $config, $eventManager);
    }
260797
public function save(string $fieldname, array $config, EntityInterface $entity = null)
    {
        if (!empty($entity[$config['name']])) {
            $assocData = $entity[$config['name']];
            if (is_array($assocData)) {
                $data = [];
                foreach ($assocData as $assocEntity) {
                    $entityTable = TableRegistry::get($assocEntity->source());
                    $data[] = $assocEntity->{$entityTable->displayField()};
                }

                return $data;
            }
        }

        return $entity[$config['name']];
    }
265859
public function findOneByBundleFQCN($fqcn)
    {
        $split = explode('\\', $fqcn);
        $dql = '
            SELECT p FROM Claroline\CoreBundle\Entity\Plugin p
            WHERE p.vendorName = :vendor
            AND p.bundleName = :bundle
        ';
        $query = $this->_em->createQuery($dql);
        $query->setParameter('vendor', $split[0]);
        $query->setParameter('bundle', $split[1]);
        $results = $query->getResult();

        return count($results) !== 0 ? $results[0] : null;
    }
312455
public static function getSingularForFqn(string $entityFqn): string
    {
        $shortName = self::getShortNameForFqn($entityFqn);
        $singular  = self::singularize($shortName);

        return lcfirst($singular);
    }
650401
protected function manageEdit($entity, Request $request, $formTypeFQCN)
    {
        $form = $this->createForm($formTypeFQCN, $entity, array(
            'action' => $this->getEditUrl($entity),
            'method' => 'POST',
        ));

        $form
            ->add('save', SubmitType::class, array('attr' => array('class' => 'btn btn-primary')))
            ->add('delete', SubmitType::class, array('attr' => array('class' => 'btn btn-danger')));

        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            if ($form->get('save')->isClicked()) {
                if ($form->isValid()) {
                    return $this->crudManage($entity, AdminCrudEvent::UPDATE);
                }
            } elseif ($form->get('delete')->isClicked()) {
                return $this->crudManage($entity, AdminCrudEvent::DELETE);
            }
        }

        return $this->render(
            $this->getEditTemplate(),
            array(
                'entity' => $entity,
                'form' => $form->createView(),
            ));
    }
1125016
public function setFQN($fqn) {
    if (FALSE !== ($pos = mb_strrpos($fqn,'\\'))) {
      $this->namespace = ltrim(mb_substr($fqn, 0, $pos+1), '\\'); // +1 to add the trailing slash, see setNamespace
      $this->setName(mb_substr($fqn, $pos));
    } else {
      $this->namespace = NULL;
      $this->setName($fqn);
    }
  }
232213
public function setEmbeddablesToEntity(string $entityFqn, array $embeddableTraitFqns): self
    {
        foreach ($embeddableTraitFqns as $embeddableTraitFqn) {
            $this->embeddableSetter->setEntityHasEmbeddable($entityFqn, $embeddableTraitFqn);
        }

        return $this;
    }