Returns an array of AbstractClassContent scheduled for insertions or updates.

@param \Doctrine\ORM\EntityManager $em
@param boolean                     $with_revision Includes AClassContent which has scheduled revision

@return array
195714
public static function getScheduledAClassContentNotForDeletions(EntityManager $em, $with_revision = false)
    {
        return array_merge(self::getScheduledAClassContentInsertions($em, $with_revision), self::getScheduledAClassContentUpdates($em, $with_revision));
    }
1367922
public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        $originClassName = $className;
        $originMetadata = $this->em->getClassMetadata('Opifer\\ContentBundle\\Entity\\ListBlock');

//
//        $metadata->name = self::REVISION_ENTITY; //. '' . str_replace('\\', '', $class->name);
//        $class->rootEntityName = $class->name;
//        $class->namespace = 'Opifer\\Revisions\\Entity';
//
//        $class->discriminatorMap = null;
//        $class->discriminatorColumn = null;

        $metadata->setPrimaryTable(['name' => $originMetadata->getTableName() . '_revisions']);


        foreach ($originMetadata->fieldMappings as $key => $fieldMapping) {
            $fieldMapping['inherited'] = self::REVISION_ENTITY;
            $fieldMapping['declared'] = self::REVISION_ENTITY;

            if ($this->annotationReader->isPropertyRevised($originClassName, $fieldMapping['fieldName'])) {
                $metadata->mapField($fieldMapping);
            }
        }

        foreach ($originMetadata->associationMappings as $key => $associationMapping) {
            $associationMapping['inherited'] = self::REVISION_ENTITY;
            $associationMapping['declared'] = self::REVISION_ENTITY;

            if ($this->annotationReader->isPropertyRevised($originClassName, $associationMapping['fieldName'])) {
                if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_ONE) {
                    $metadata->mapOneToOne($associationMapping);
                } else if ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_ONE) {
                    $metadata->mapManyToOne($associationMapping);
                } else if ($associationMapping['type'] == ClassMetadataInfo::ONE_TO_MANY) {
                    $metadata->mapOneToMany($associationMapping);
                } else if ($associationMapping['type'] == ClassMetadataInfo::MANY_TO_MANY) {
                    $metadata->mapManyToMany($associationMapping);
                }
            }

        }
    }
130423
private function updateCompressedHubProperty(EntityManager $em, $entity)
    {
        $entityClass = get_class($entity);
        $hash = spl_object_hash($entity);
        $classMetadata = $em->getClassMetadata($entityClass);

        $pathHub = MetadataLayer::PATH_HUB;
        $pathMaskGrouped = MetadataLayer::PATH_MASK_BY_HUB;

        $maskListGrouped = !empty($classMetadata->$pathMaskGrouped) ? $classMetadata->$pathMaskGrouped : [];
        $hubList = !empty($classMetadata->$pathHub) ? $classMetadata->$pathHub : [];

        $is_updated = false;
        foreach ($hubList as $hubData) {
            /** @var \ReflectionProperty $hubReflection */
            $hubReflection = $hubData['reflection'];

            $valueList = [];
            if (!isset($maskListGrouped[$hubReflection->getName()])) {
                continue;
            }

            foreach ($maskListGrouped[$hubReflection->getName()] as $maskData) {
                /** @var \ReflectionProperty $maskReflection */
                $maskReflection = $maskData['reflection'];
                $value = $maskReflection->getValue($entity);
                if (isset($this->originalData[$entityClass][$hash][$maskReflection->getName()])) {
                    if ($this->originalData[$entityClass][$hash][$maskReflection->getName()] == $value) {
                        // nothing was changed, we can skip it
                        continue;
                    }
                }
                if (!$value) {
                    $value = 0;
                }
                $valueList[$maskReflection->getName()] = $value;
            }

            if (empty($valueList)) {
                continue;
            }

            $oldHubValue = $hubReflection->getValue($entity);
            if (!$oldHubValue) {
                $oldHubValue = 0;
            }
            $newHubValue = $this->engine->getPackedValue(
                $oldHubValue,
                $maskListGrouped[$hubReflection->getName()],
                $valueList
            );
            if ($oldHubValue !== $newHubValue) {
                $hubReflection->setValue($entity, $newHubValue);
                $is_updated = true;
            }
        }

        return $is_updated;
    }
114658
public function getDocComment ( $withCommentMark = false ) {
        $docComment = $this->_reflectionClass->getDocComment();
        if ( $withCommentMark === false ) {
            $docComment = PhpDocCommentObject::stripCommentMarks($docComment);
        }
        return $docComment;
    }
1269236
public function getRepository(EntityManagerInterface $entityManager, $entityName)
    {
        if (!in_array($entityName, $this->alreadyChecked) && isset($this->customEntyRepository[$entityName])) {
            $repositoryClass = $this->customEntyRepository[$entityName];
            if (!class_exists($repositoryClass)) {
                throw new \InvalidArgumentException(sprintf(
                    'Class %s does not exist. Cannot be used as %s custom repository.',
                    $repositoryClass,
                    $entityName
                ));
            }

            $metadata = $entityManager->getClassMetadata($entityName);
            $metadata->customRepositoryClassName = $repositoryClass;
        }

        $this->alreadyChecked[] = $entityName;

        return parent::getRepository($entityManager, $entityName);
    }
835160
protected function updateEntityRevision(Entity $entity, $revision, FormData $requestData) {
    $this->setRevisionMetadata($revision);
    
    $this->beginTransaction();
    
    // validiert und processed die daten aus requestData und setzt diese im Entity
    $this->processEntityFormRequest($entity, $requestData, $revision);

    $this->repository->save($entity);
    
    $this->commitTransaction();
    
    $this->setEntityResponseMetadata($entity);
    
    return $entity;
  }
157033
public function getRef(EntityManager $em, $type = 'public')
    {
        $nodeVersion = $this->getNodeVersion($type);
        if ($nodeVersion) {
            return $em->getRepository($nodeVersion->getRefEntityName())->find($nodeVersion->getRefId());
        }

        return null;
    }
1146787
private function buildDeleteQuery(EntityManagerInterface $em)
    {
        $qb = $em->createQueryBuilder()
            ->delete($this->sharingClass, 's')
        ;

        $this->buildCriteria($qb, $this->deleteSharingSubjects, 'subjectClass', 'subjectId');
        $this->buildCriteria($qb, $this->deleteSharingIdentities, 'identityClass', 'identityName');

        return $qb->getQuery();
    }
191542
private function executeRevert(AbstractClassContent $content, Revision $draft, array $data)
    {
        $content->setDraft(null);
        if ($content instanceof ContentSet) {
            if (isset($data['elements']) && true === $data['elements']) {
                $draft->clear();
                foreach ($content->getData() as $element) {
                    if ($element instanceof AbstractClassContent) {
                        $draft->push($element);
                    }
                }
            }
        } else {
            foreach ($content->getData() as $key => $element) {
                if (isset($data['elements']) && in_array($key, $data['elements'])) {
                    $draft->$key = $content->$key;
                }

                if (in_array('Element\Keyword', $content->getAccept()[$key])) {
                    $this->entityManager
                        ->getRepository('BackBee\ClassContent\Element\Keyword')
                        ->cleanKeywordLinks($content, $element);
                }
            }
        }

        if (isset($data['parameters'])) {
            foreach ($content->getDefaultParams() as $key => $params) {
                if (in_array($key, $data['parameters'])) {
                    $draft->setParam($key, $content->getParamValue($key));
                }
            }
        }

        return $this;
    }
902794
public function getByEntity($entityClass, $id, $locale, $object = null)
    {
        $metadata = $this->structureMetadataFactory->getStructureMetadata('page', $object->getStructureType());

        return [
            '_controller' => $metadata->getController(),
            'view' => $metadata->getView(),
            'object' => $object,
            'structure' => $this->documentToStructure($object),
        ];
    }
1277021
private static function updateSuperContentIndexes(AbstractClassContent $content)
    {
        $alreadyIndexed = self::$em->getRepository('BackBee\ClassContent\Indexation')->findBy(['_owner' => $content]);
        foreach ($alreadyIndexed as $index) {
            if (null === $field = $index->getField()) {
                continue;
            }

            list($value, $owner) = self::getIndexValue($index->getContent(), $field);

            $callback = unserialize($index->getCallback());
            if (null !== $callback) {
                $value = self::applyCallbacks($value, (array) $callback);
            }

            if (null !== $value) {
                $index->setValue($value);
                self::$em->getRepository('BackBee\ClassContent\Indexation')->save($index);
            }
        }
    }
202014
private function createEntityCacheKey(ClassMetadata $classMetadata, array $data, $revision)
    {
        $keyParts = array();

        foreach ($classMetadata->getIdentifierFieldNames() as $name) {
            if ($classMetadata->hasAssociation($name)) {
                if ($classMetadata->isSingleValuedAssociation($name)) {
                    $name = $classMetadata->getSingleAssociationJoinColumnName($name);
                } else {
                    // Doctrine should throw a mapping exception if an identifier
                    // that is an association is not single valued, but just in case.
                    throw new \RuntimeException('Multiple valued association identifiers not supported');
                }
            }
            $keyParts[] = $data[$name];
        }

        return $classMetadata->name . '_' . implode('_', $keyParts) . '_' . $revision;
    }
1131423
public function getNodeInformation($entityClass = '',
        $parentEntity = null)
    {
        if ($entityClass === '') {
            throw new Exception('messages.error.classNameNotProvided');
        }
        $tree = [];
        if ($parentEntity === null) {
            $dql = '
                SELECT
                    (COALESCE(MAX(a.rgt), 0) + 1) AS lft,
                    (COALESCE(MAX(a.rgt), 0) + 2) AS rgt
                FROM ' . $entityClass . ' a
            ';
            $a = $this->query($dql);
            $ordering = $a->getResult();

            $tree['depth'] = 0;
            $tree['lft'] = $ordering[0]['lft'];
            $tree['rgt'] = $ordering[0]['rgt'];
        } else {
            $this->rebuildTree($entityClass, $parentEntity);
            $tree['depth'] = $parentEntity->depth + 1;
            $tree['lft'] = $parentEntity->rgt;
            $tree['rgt'] = $parentEntity->rgt + 1;
        }
        return $tree;
    }
788460
public function getIdentifierColumns(EntityManagerInterface $em) : array
    {
        $columns = [];

        foreach ($this->identifier as $idProperty) {
            $property = $this->getProperty($idProperty);

            if ($property instanceof FieldMetadata) {
                $columns[$property->getColumnName()] = $property;

                continue;
            }

            /** @var AssociationMetadata $property */

            // Association defined as Id field
            $targetClass = $em->getClassMetadata($property->getTargetEntity());

            if (! $property->isOwningSide()) {
                $property    = $targetClass->getProperty($property->getMappedBy());
                $targetClass = $em->getClassMetadata($property->getTargetEntity());
            }

            $joinColumns = $property instanceof ManyToManyAssociationMetadata
                ? $property->getJoinTable()->getInverseJoinColumns()
                : $property->getJoinColumns();

            foreach ($joinColumns as $joinColumn) {
                /** @var JoinColumnMetadata $joinColumn */
                $columnName           = $joinColumn->getColumnName();
                $referencedColumnName = $joinColumn->getReferencedColumnName();

                if (! $joinColumn->getType()) {
                    $joinColumn->setType(PersisterHelper::getTypeOfColumn($referencedColumnName, $targetClass, $em));
                }

                $columns[$columnName] = $joinColumn;
            }
        }

        return $columns;
    }
274774
private function getClassExtends()
    {
        if( $this->isMultiton() ) {
            $this->class->addUses('\Bond\Repository\Multiton as RM');
            $this->class->addExtends('RM');
        } else {
            $this->class->addUses('\Bond\Repository as R');
            $this->class->addExtends('R');
        }

    }
905869
public function getAllVersionsOfEntity(DocumentationEntity $entity)
    {
        $all = new ArrayList();

        foreach ($this->getEntities() as $check) {
            if ($check->getKey() == $entity->getKey()) {
                if ($check->getLanguage() == $entity->getLanguage()) {
                    $all->push($check);
                }
            }
        }

        return $all;
    }
291339
protected function getCriteria($entity, Constraint $constraint, ObjectManager $em)
    {
        /** @var UniqueEntity $constraint */
        /** @var \Doctrine\ORM\Mapping\ClassMetadata $class */
        $class = $em->getClassMetadata(ClassUtils::getClass($entity));
        $fields = (array) $constraint->fields;
        $criteria = [];

        foreach ($fields as $fieldName) {
            $criteria = $this->findFieldCriteria($criteria, $constraint, $em, $class, $entity, $fieldName);

            if (null === $criteria) {
                break;
            }
        }

        return $criteria;
    }