Get the existing document or proxy for this id of this class, or create
a new one.

@param string $targetId
@param string $className
@param string $locale

@return object
8176
public function getOrCreateProxy($targetId, $className, $locale = null)
    {
        $document = $this->getDocumentById($targetId);

        // check if referenced document already exists
        if ($document) {
            $metadata = $this->dm->getClassMetadata($className);
            if ($locale && $locale !== $this->getCurrentLocale($document, $metadata)) {
                $this->doLoadTranslation($document, $metadata, $locale, true);
            }

            return $document;
        }

        $metadata = $this->dm->getClassMetadata($className);
        $proxyDocument = $this->dm->getProxyFactory()->getProxy($className, [$metadata->identifier => $targetId]);

        // register the document under its own id
        $this->registerDocument($proxyDocument, $targetId);

        if ($locale) {
            $this->setLocale($proxyDocument, $this->dm->getClassMetadata($className), $locale);
        }

        return $proxyDocument;
    }
403479
private function getIndexQueryBuilder($locale, array $filterFormData = null)
    {
        $qb = $this->getEntityManager()->getRepository($this->entityClass)->createQueryBuilder('o');

        foreach ($this->configuration['joins'] as $alias => $join) {
            if (false === strpos($join, '.')) {
                $join = 'o.'.$join;
            }

            $qb->addSelect($alias)->leftJoin($join, $alias);
        }

        $translationJoiner = $this->getTranslationJoiner();

        if ($translationJoiner->isTranslatable($this->entityClass)) {
            $translationJoiner->joinTranslation($qb, true, $locale);
        }
        if (empty($filterFormData)) {
            return $qb;
        }

        $filtererOptions = ['non_strict_comparison_fields' => []];
        $getNonStrictComparisonFields = function (array $fields) use (&$filtererOptions) {
            foreach ($fields as $field => $attr) {
                if (!$attr['compare_strict']) {
                    $filtererOptions['non_strict_comparison_fields'][] = $field;
                }
            }
        };
        $getNonStrictComparisonFields($this->configuration['form']['filter']['fields']);
        array_map($getNonStrictComparisonFields, $this->configuration['form']['filter']['field_groups']);

        $this->getFilterer()->filter($qb, $filterFormData, $filtererOptions);

        return $qb;
    }
250647
protected function copyWebspace($localeSource, $localeDestination)
    {
        $this->output->writeln([
            '------------------------------',
            '<info>Webspace: </info>' . $this->webspaceKeySource . ' => ' . $this->webspaceKeyDestination,
            '<info>Locale: </info>' . $localeSource . ' => ' . $localeDestination,
            '------------------------------',
        ]);

        /** @var HomeDocument $homeDocumentSource */
        $homeDocumentSource = $this->documentManager->find(
            $this->sessionManager->getContentPath($this->webspaceKeySource),
            $localeSource
        );

        // Generate all needed page documents.
        $this->recursiveCopy(
            $homeDocumentSource,
            null,
            $localeDestination
        );

        $this->output->writeln([
            '------------------------------',
            '',
        ]);
    }
953254
public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias)
    {
        // Check if the entity implements the Page entity
        if ($targetEntity->reflClass->getName() !== 'Fulgurio\LightCMSBundle\Entity\Page')
        {
            return '';
        }
        return $targetTableAlias . '.status = ' . $this->getParameter('status');
    }
295420
public function buildJunctionJoinColumnName(\ReflectionClass $targetClass, string $targetIdPropertyName, 
			string $joinColumnName = null): string {
		if ($joinColumnName !== null) return $joinColumnName;
		
		return StringUtils::hyphenated($targetClass->getShortName() . ucfirst($targetIdPropertyName));
	}
1361376
public function getSqlConstraint(ClassMetadata $targetEntity, $targetTableAlias)
    {
        $this->evaluateMatcher();

        /** @var EntityManager $entityManager */
        $entityManager = $this->objectManager->get(EntityManagerInterface::class);
        $sqlFilter = new SqlFilter($entityManager);

        if (!$this->matchesEntityType($targetEntity->getName())) {
            return null;
        }

        return $this->conditionGenerator->getSql($sqlFilter, $targetEntity, $targetTableAlias);
    }
224018
protected function getPreview($id, $locale)
    {
        $medias = $this->mediaRepository
            ->findMedia(['collection' => $id, 'paginator' => false], 1);

        if (count($medias) > 0) {
            $media = $medias[0];
            foreach ($media->getFiles() as $file) {
                foreach ($file->getFileVersions() as $fileVersion) {
                    if ($fileVersion->getVersion() == $file->getVersion()) {
                        $format = $this->getPreviewsFromFileVersion($media->getId(), $fileVersion, $locale);

                        if (!empty($format)) {
                            return $format;
                        }
                    }
                }
            }
        }

        return;
    }
917585
public function get($id, $className, callable $findOneCallable, callable $deleteCallable)
    {
        try {
            $data = $findOneCallable();
            if (empty($data)) {
                $mapping = $this->serializer->getTransformer()->getMappingByClassName($className);

                return $this->resourceNotFound(new ErrorBag([new NotFoundError($mapping->getClassAlias(), $id)]));
            }

            $deleteCallable();

            return $this->resourceDeleted();
        } catch (Exception $e) {
            return $this->getErrorResponse($e);
        }
    }
816077
public function parse(\Imi\Bean\Annotation\Base $annotation, string $className, string $target, string $targetName)
    {
        if($annotation instanceof EnumItem)
        {
            $value = constant($className . '::' . $targetName);
            $this->data['names'][$className][] = $targetName;
            $this->data['EnumItem'][$className][$value] = $annotation;
        }
    }
341533
public function getUnreviewedSelectQuery(LocaleEntity $locale)
    {
        $cn = $this->app->make(EntityManager::class)->getConnection();
        $queryLocaleID = $cn->quote($locale->getID());

        return $cn->executeQuery(
            $this->getBaseSelectString($locale, false, false) .
            " inner join
                (
                    select distinct
                        translatable
                    from
                        CommunityTranslationTranslations
                    where
                        locale = $queryLocaleID
                        and
                        (
                            (approved is null)
                            or
                            (current = 1 and approved = 0)
                        )
                ) as tNR on CommunityTranslationTranslatables.id = tNR.translatable
            order by
                CommunityTranslationTranslatables.text
            "
        );
    }
202694
public static Object getTranslatedObject(Object value, Class<?> sourceClass, Class<?> targetClass)
    {
        if (sourceClass.isAssignableFrom(Date.class))
        {
            value = PropertyAccessorHelper.fromDate(targetClass, sourceClass, value);
        }
        else
        {
            value = PropertyAccessorHelper.fromSourceToTargetClass(targetClass, sourceClass, value);
        }
        return value;
    }
393533
public function parse(\Imi\Bean\Annotation\Base $annotation, string $className, string $target, string $targetName)
    {
        if($annotation instanceof \Imi\Bean\Annotation\ClassEventListener)
        {
            if(!isset($this->data[$annotation->className][$annotation->eventName]))
            {
                $this->data[$annotation->className][$annotation->eventName] = [];
            }
            $this->data[$annotation->className][$annotation->eventName][] = [
                'className' => $className,
                'priority'  => $annotation->priority,
            ];
        }
    }
1312521
private function getResource($uuid, $locale)
    {
        return $this->proxyFactory->createProxy(
            ArticleDocument::class,
            function (
                &$wrappedObject,
                LazyLoadingInterface $proxy,
                $method,
                array $parameters,
                &$initializer
            ) use ($uuid, $locale) {
                $initializer = null;
                $wrappedObject = $this->documentManager->find($uuid, $locale);

                return true;
            }
        );
    }
736344
private function getArticleContentMap(string $sourceLanguage, string $targetLanguage): ArticleContentMap
    {
        if (!array_key_exists($key = $sourceLanguage . '->' . $targetLanguage, $this->articleContentMaps)) {
            return $this->articleContentMaps[$key] = new ArticleContentMap(
                $this->getArticleMap($sourceLanguage, $targetLanguage),
                $this->logger
            );
        }

        return $this->articleContentMaps[$key];
    }
1283045
public static function objectSerialize($targetObject, $rootName)
    {
        Validate::notNull($targetObject, 'targetObject');
        Validate::isString($rootName, 'rootName');

        $container = new \stdClass();

        $container->$rootName = $targetObject;

        return json_encode($container);
    }
744768
public function getParentPagesChoices($locale, $id = null)
    {
        $qb = $this->getParentPagesQuery($locale, $id);

        return $qb->getQuery()->execute();
    }
569673
private function checkIfTargetLocaleTranslationsExist(array $translationClasses, $targetLocale)
    {
        $localeProperty = $this->translatableManager->getTranslationLocaleProperty();

        foreach ($translationClasses as $translationClass) {
            $translationsCount = $this->em->getRepository($translationClass)->createQueryBuilder('o')
                ->select('COUNT(o)')
                ->where(sprintf('o.%s = :%1$s', $localeProperty))
                ->setParameter($localeProperty, $targetLocale)
                ->getQuery()
                ->getSingleScalarResult();

            if ($translationsCount > 0) {
                throw new TranslatableException(
                    sprintf('Translations for locale "%s" already exist in repository "%s".', $targetLocale, $translationClass)
                );
            }
        }

        return $this;
    }