Erstellt einen Synchronizer für das $collectionPropertyName in $entityClass

@return PersistentCollectionSynchronizer
490198
public static function createFor($entityClass, $collectionPropertyName, DCPackage $dc) {
    $entityMeta = $dc->getEntityMeta($entityClass);
    $property = $entityMeta->getPropertyMeta($collectionPropertyName);
    $collectionClass = $property->getRelationEntityClass();
    
    $synchronizer = new static(
      $entityMeta,
      $property->getName(),
      new UniqueEntityHydrator($dc->getEntityManager()->getRepository($collectionClass->getFQN())),
      new EntityFactory($dc->getEntityMeta($collectionClass->getFQN()))
    );
    
    return $synchronizer;
  }
1058270
private function createReferenceManyWithRepositoryMethodIterator(PersistentCollectionInterface $collection)
    {
        $mapping          = $collection->getMapping();
        $repositoryMethod = $mapping->repositoryMethod;
        $repository       = $this->dm->getRepository($mapping->targetDocument);
        $iterator         = $repository->$repositoryMethod($collection->getOwner());

        if (!$iterator instanceof Iterator) {
            throw new \BadMethodCallException(sprintf('Expected repository method %s to return an iterable object', $repositoryMethod));
        }

        if (!empty($mapping->prime)) {
            $referencePrimer = new ReferencePrimer($this->dm, $this->dm->getUnitOfWork());
            $primers         = array_combine($mapping->prime, array_fill(0, count($mapping->prime), true));
            $class           = $this->dm->getClassMetadata($mapping['targetDocument']);

            $iterator = new PrimingIterator(
                $iterator,
                $class,
                $referencePrimer,
                $primers,
                $collection->isReadOnly()
            );
        }

        return $iterator;
    }
504904
private function setUp($collectionClass, MajoraNormalizer $normalizer)
    {
        if (empty($collectionClass) || !class_exists($collectionClass)) {
            throw new \InvalidArgumentException(sprintf(
                'You must provide a valid EntityCollection class name, "%s" given.',
                $collectionClass
            ));
        }
        $this->entityCollection = new $collectionClass();
        if (!$this->entityCollection instanceof EntityCollection) {
            throw new \InvalidArgumentException(sprintf(
                'Provided class name is not an Majora\Framework\Model\EntityCollection, "%s" given.',
                $collectionClass
            ));
        }

        $this->normalizer = $normalizer;
    }
559415
public function findByCollectionNameIterator($collectionName)
    {
        /** @var QueryBuilder $queryBuilder */
        $queryBuilder = $this->entityManager->createQueryBuilder();
        return $queryBuilder
            ->select('PersistentResource')
            ->from($this->getEntityClassName(), 'PersistentResource')
            ->where('PersistentResource.collectionName = :collectionName')
            ->setParameter(':collectionName', $collectionName)
            ->getQuery()->iterate();
    }
145708
public function registerPredefinedGroupItemsSynchronizer(PredefinedGroupItemsSynchronizer $synchronizer)
    {
        $family = $synchronizer->getFamily();

        if(array_key_exists($family, $this->predefinedGroupItemsSynchronizers))
        {
            throw new CoreException('Синхронизатор предопределенных элементов групп пакета '.$family.' уже зарегестрирована в медиаторе!');
        }

        $this->predefinedGroupItemsSynchronizers[$family] = $synchronizer;
    }
584651
public function getSynchronizationCallback($entity)
    {
        $annotation = $this->getClassAnnotation($entity, self::SYNCHRONIZATION_FILTER_CLASS);

        if (!$annotation) {
            return '';
        }

        return $annotation->callback;
    }
106789
public function synchronizeCollectionNormal($entity, $field, $toCollection, Type $type) {
    if (!$this->dc) {
      throw new \RuntimeException('DCPackage muss für synchronizeCollectionNormal gesetzt sein');
    }
    
    $entityMeta = $this->dc->getEntityMeta($entity->getEntityName());
    $entityClassMeta = $entityMeta->getClassMetadata();
    $entityAssoc = $entityClassMeta->getAssociationMapping($field);
    $fromCollection = $entity->callGetter($field);
    
    if (!$entityClassMeta->isCollectionValuedAssociation($field)) {
      throw new \RuntimeException('Das Property '.$entity->getEntityName().'->'.$field.' ist keine Collection und kann somit nicht synchronisiert werden');
    }
      
    $adder = $remover = NULL;
    
    if ($entityClassMeta->isAssociationInverseSide($field)) {
      $otherMeta = $this->dc->getEntityMeta($entityAssoc['targetEntity']);
      $otherMetaClass = $otherMeta->getClassMetadata();
      $otherProperty = $entityAssoc['mappedBy'];
      $otherIsCollection = $otherMetaClass->isCollectionValuedAssociation($otherProperty);
      
      $addOrSet = $otherIsCollection
              ? 'add'.ucfirst($otherProperty)
              : 'set'.ucfirst($otherProperty);
      
      // da der CollectionSynchronizer nur die owningSide automatisch pflegt, injecten wir hier den adder und remover um die inverse Side zu pflegen
      $adder = function ($entity, $toEntity, $repository) use ($addOrSet) {
        $repository->persist($toEntity);
        $toEntity->$addOrSet($entity);
      };

      if ($otherIsCollection) {
        $remove = 'remove'.ucfirst($otherProperty);
        $remover = function ($entity, $toEntity, $repository) use ($remove) {
          $repository->persist($toEntity);
          $toEntity->$remove($entity);
        };
      } else {
        $set = 'set'.ucfirst($otherProperty);
        $remover = function ($entity, $toEntity, $repository) use ($set) {
          $repository->persist($toEntity);
          $toEntity->$set(NULL);
        };
      }
    }
    
    $synchronizer = CollectionSynchronizer::createFor($entity->getEntityName(), $field, $this->dc);
    $synchronizer->init($entity, $adder, $remover);
    return $synchronizer->process($fromCollection, $toCollection);
  }
1304104
public function getModelCollection(EntityMetadata $metadata)
    {
        if (!$metadata->persistence instanceof StorageMetadata) {
            throw PersisterException::badRequest('Wrong StorageMetadata type');
        }
        return $this->connection->selectCollection($metadata->persistence->db, $metadata->persistence->collection);
    }
961053
protected function denormalizeCollection($collection, $class, $name, $format = null, array $context = array())
    {
        /** @var ClassMetadata $meta */
        $meta = $context['entityMeta'];

        $targetEntity = $meta->associationMappings[$name]['targetEntity'];

        $result = array();
        foreach ($collection as $key => $element) {
            $class = $class ?: $targetEntity;

            $result[$key] = $this->denormalizeAssociation($element, $class, $name, $format, $context);
        }

        return $result;
    }
727175
public function getObjectsByCollection(CollectionInterface $collection, callable $callback = null)
    {
        $iterator = $this->resourceRepository->findByCollectionNameIterator($collection->getName());
        $iteration = 0;
        foreach ($this->resourceRepository->iterate($iterator, $callback) as $resource) {
            /** @var PersistentResource $resource */
            $object = new StorageObject();
            $object->setFilename($resource->getFilename());
            $object->setSha1($resource->getSha1());
            $object->setMd5($resource->getMd5());
            $object->setFileSize($resource->getFileSize());
            $object->setStream(function () use ($resource) {
                return $this->getStreamByResource($resource);
            });
            yield $object;
            if (is_callable($callback)) {
                call_user_func($callback, $iteration, $object);
            }
            $iteration++;
        }
    }
81876
public function getOwnSynchronizer($family)
    {
        if(!array_key_exists($family, $this->synchronizersOwn))
        {
            throw new CoreException('Синхронизатор полей типа пакета '.$family.' не найдена в медиаторе!');
        }

        return $this->synchronizersOwn[$family];
    }
398504
public function getRepository($entityClass)
    {
        if (is_object($entityClass)) {
            $entityClass = get_class($entityClass);
        }

        if (!isset($this->repositories[$entityClass])) {
            throw new \Exception("no repository defined for: $entityClass");
        }

        if (!is_object($this->repositories[$entityClass])) {
            $this->repositories[$entityClass] = $this->di->get($this->repositories[$entityClass]);
        }

        return $this->repositories[$entityClass];
    }
331979
private static function getDataMapperInstance()
    {
        $instance = Ioc::make(get_called_class());

        if (!$instance->getCollectionName()) {
            throw new NoCollectionNameException();
        }

        return $instance->getDataMapper();
    }
101997
private function deleteEntityCollection(PersistentCollection $collection)
    {
        $association  = $collection->getMapping();
        $identifier   = $this->uow->getEntityIdentifier($collection->getOwner());
        $sourceClass  = $this->em->getClassMetadata($association->getSourceEntity());
        $targetClass  = $this->em->getClassMetadata($association->getTargetEntity());
        $inverseAssoc = $targetClass->getProperty($association->getMappedBy());
        $columns      = [];
        $parameters   = [];

        foreach ($inverseAssoc->getJoinColumns() as $joinColumn) {
            $columns[]    = $this->platform->quoteIdentifier($joinColumn->getColumnName());
            $parameters[] = $identifier[$sourceClass->fieldNames[$joinColumn->getReferencedColumnName()]];
        }

        $tableName = $targetClass->table->getQuotedQualifiedName($this->platform);
        $statement = 'DELETE FROM ' . $tableName . ' WHERE ' . implode(' = ? AND ', $columns) . ' = ?';

        return $this->conn->executeUpdate($statement, $parameters);
    }
1253526
public function getPersistenceBuilder() : PersistenceBuilder
    {
        if (! $this->persistenceBuilder) {
            $this->persistenceBuilder = new PersistenceBuilder($this->dm, $this);
        }
        return $this->persistenceBuilder;
    }
96531
public function loadCollection(PersistentCollectionInterface $collection)
    {
        $this->getDocumentPersister(get_class($collection->getOwner()))->loadCollection($collection);
        $this->lifecycleEventManager->postCollectionLoad($collection);
    }
676275
public function findPaginated(
        $entityClass,
        array $criteria,
        $sorting = [],
        $offset = Request\Params::DEFAULT_PAGE_OFFSET,
        $limit = Request\Params::DEFAULT_PAGE_SIZE,
        $translatable = false
    )
    {
        $qb = $this->getQueryBuilder($entityClass, $criteria, $sorting, $translatable);
        
        $qb->setFirstResult($offset)
            ->setMaxResults($limit);

        $paginator = new Paginator($qb->getQuery());
        $collection = new PaginatedCollection($paginator);

        return $collection;
    }