setUp method.

@param string              $entityClass
@param array               $entityProperties
@param string              $collectionClass
@param RepositoryInterface $entityRepository
509960
public function setUp(
        $entityClass,
        array $entityProperties,
        $collectionClass,
        RepositoryInterface $entityRepository = null
    ) {
        @trigger_error(__METHOD__.'() is deprecated and will be removed in 2.0. Please use configureMetadata() instead.', E_USER_DEPRECATED);

        if ($entityRepository) {
            @trigger_error('Repository injection throught '.__METHOD__.'() is deprecated and will be removed in 2.0. Please inject it by constructor.', E_USER_DEPRECATED);

            $this->entityRepository = $entityRepository;
        }

        return $this->configureMetadata($entityClass, $entityProperties, $collectionClass);
    }
180774
public function initialize(Entity\Entity $entity)
    {
        $this->setupContenttype($entity);
        $this->setupContainer($entity);
    }
176726
public function castToEntity($matches, $entityClass)
    {
        $entityRegistry = $this->repositoryFactory->getEntityRegistry();

        $result = [];

        $meta        = $this->getMeta($entityClass);
        $entityClass = $meta->class;
        $reflection  = new \ReflectionClass($entityClass);

        foreach ($matches as $match) {
            $entity = new $entityClass;

            foreach ($meta->fields as $key => $definition) {
                /** @var Element $definition */
                $varName = $definition->propertyName($key);
                $colName = $definition->columnName($key);

                $value = isset($definition->default) ? $definition->default : null;

                if (array_key_exists($colName, $match)) {
                    // @todo Apply validation according to definition
                    $value = $match[$colName];

                    if ($definition instanceof Field) {
                        switch ($definition->type) {
                            case 'int':
                            case 'integer':
                                $value = (integer)$value;
                                break;

                            case 'json':
                                $value = json_decode($value);
                                break;

                            default:
                                // Leave the value alone
                                break;
                        }
                    }
                }

                if ($reflection->hasProperty($varName)) {
                    $property = $reflection->getProperty($varName);
                    $property->setAccessible(true);
                    $property->setValue($entity, is_null($value) ? $entity->{$varName} : $value);
                } else {
                    /** @noinspection PhpVariableVariableInspection */
                    $entity->{$varName} = $value;
                }
            }

            $entityRegistry->stashEntity($entity);
            $this->resolveRelations($entity, $meta);
            $entityRegistry->registerEntity($entity);

            $result[] = $entity;

            unset($entity);
        }

        return $result;
    }
365483
public function setEntityProperty(?EntityProperty $entityProperty) {
		ArgUtils::assertTrue($entityProperty instanceof EmbeddedEntityProperty);
		
		parent::setEntityProperty($entityProperty);
	}
82419
public function setEntity($entity, $entityId)
    {
        //set the entity
        $method = 'set'.ucfirst($entityId);

        //set the entity
        call_user_func([$this, $method], $entity);
    }
594253
@Override
  public <T> void dropCollection(Class<T> entityClass) {
    dropCollection(Util.determineCollectionName(entityClass));
  }
362248
public function setCustomRepositoryClass(?string $repositoryClassName) : void
    {
        if ($this->isEmbeddedDocument || $this->isQueryResultDocument) {
            return;
        }

        $this->customRepositoryClassName = $repositoryClassName;
    }
707780
private function buildEntityClass()
    {
        foreach ($this->registries as $registry) {
            if ($registry->getKey() === 'identifier') {
                $this->entity->setObjectIdentifier($registry->getValue());
            } else {
                $this->entity->setObjectProperty($registry->getKey(), $registry->getValue());
            }
        }
    }
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;
  }
317437
public function mapEntities(array $entityDefinitions)
	{
		foreach($entityDefinitions as $entityIdentifier => $entityDefinition)
		{
			$this->validateAndCompleteEntity($entityIdentifier, $entityDefinition);
		}
	}
1043548
public function setTables($entityTables, $manyToManyTables)
    {
        $this->tables = $this->manyToManyTables = $this->classToTableNames = [];

        foreach ($entityTables as $table) {
            $className = $this->getClassNameForTable($table->getName());

            $this->classToTableNames[$className] = $table->getName();
            $this->tables[$table->getName()]     = $table;
        }

        foreach ($manyToManyTables as $table) {
            $this->manyToManyTables[$table->getName()] = $table;
        }
    }
928754
private void setRelationToEntity(Object entity, Object relationEntity, Relation relation)
    {
        if (relation.getTargetEntity().isAssignableFrom(getEntity(relationEntity).getClass()))
        {

            if (relation.isUnary())
            {
                PropertyAccessorHelper.set(entity, relation.getProperty(), getEntity(relationEntity));
            }
            else
            {
                Object associationObject = PropertyAccessorHelper.getObject(entity, relation.getProperty());
                if (associationObject == null || ProxyHelper.isProxyOrCollection(associationObject))
                {
                    associationObject = PropertyAccessorHelper.getCollectionInstance(relation.getProperty());
                    PropertyAccessorHelper.set(entity, relation.getProperty(), associationObject);
                }

                ((Collection) associationObject).add(getEntity(relationEntity));
            }
        }
    }
1064474
public function toEntity(
        $parent,
        ResourceTransformer $resourceTransformer,
        PropertyResolver $propertyResolver,
        PropertySetter $propertySetter,
        EntityFactory $factory,
        Context $context
    ) {
        $children = $this->getChildrenToProcess();

        $childrenToAdd = [];
        $childrenToEdit = [];

        /**
         * Keep a list of all identifies we've touched, so we can removed those we haven't
         * @var PropertyValueCollection[] $identifiersToKeep
         */
        $identifiersToKeep = [];

        /** @var RelationshipField $field */
        $field = $this->getField();

        foreach ($children as $child) {
            if (!$child) {
                continue;
            }

            /** @var RESTResource $child */

            /** @var bool $isNew */
            $isNew = $child->isNew();

            $childIdentifiers = $child->getProperties()->getIdentifiers();

            $childEntity = null;
            if (!$isNew) {
                $childEntity = $this->getChildByIdentifiers(
                    $resourceTransformer,
                    $propertyResolver,
                    $parent,
                    $childIdentifiers,
                    $context
                );

                if ($childEntity) {
                    $identifiersToKeep[] = $childIdentifiers;
                }
            }

            // Do we just link the resource? In this case we can't edit it right now.
            if ($field->canLinkExistingEntities()) {
                $entity = $factory->resolveLinkedEntity(
                    $parent,
                    $child->getResourceDefinition()->getEntityClassName(),
                    $childIdentifiers->toMap(),
                    $context
                );

                if ($entity) {
                    $childrenToAdd[] = $entity;
                    $identifiersToKeep[] = $childIdentifiers;
                    continue;
                }
            }

            // Is this a new child? We might not be able to add it...
            if (!$childEntity && !$field->canCreateNewChildren()) {
                throw new InvalidPropertyException(
                    "Only existing items can be linked to " . get_class($parent) . "->" . $field->getName()
                );
            }

            $entity = $resourceTransformer->toEntity(
                $child,
                $child->getResourceDefinition(),
                $factory,
                $context,
                $childEntity
            );

            if (!isset($childEntity)) {
                $childrenToAdd[] = $entity;
            } else {
                $childrenToEdit[] = $entity;
            }
        }

        if (count($childrenToAdd) > 0) {
            $this->addChildren(
                $resourceTransformer,
                $propertySetter,
                $parent,
                $this->getField(),
                $childrenToAdd,
                $context
            );
        }

        if (count($childrenToEdit) > 0) {
            $this->editChildren(
                $resourceTransformer,
                $propertySetter,
                $parent,
                $this->getField(),
                $childrenToEdit,
                $context
            );
        }

        // Notify the setter to remove all children that haven't been touched (in the range defined in the context)
        $this->removeAllChildrenExcept(
            $resourceTransformer,
            $propertyResolver,
            $propertySetter,
            $parent,
            $this->getField(),
            $identifiersToKeep,
            $context
        );
    }
640524
private function getSourcePropertyValues(array $sourcePropertyPaths, $entity, $entityClass)
    {
        $sourcePropertyValues = [];

        foreach ($sourcePropertyPaths as $sourcePropertyPath) {
            if (!$this->propertyAccessor->isReadable($entity, $sourcePropertyPath)) {
                throw $this->createPropertyNotReadableException($entityClass, $sourcePropertyPath);
            }

            $sourcePropertyValues[$sourcePropertyPath] = $this->propertyAccessor->getValue($entity, $sourcePropertyPath);
        }

        return $sourcePropertyValues;
    }
824057
@Override
  public <T> void save(Object objectToSave, Class<T> entityClass) {
    save(objectToSave, Util.determineCollectionName(entityClass));
  }
1123253
public function setEntityClass($entityClass)
    {
        if (!is_string($entityClass)) {
            throw new \InvalidArgumentException('The attribute entityClass on the class Project has to be string (' . gettype($entityClass) . ('object' === gettype($entityClass) ? ' ' . get_class($entityClass) : '') . ' given).');
        }

        $this->entityClass = $entityClass;

        return $this;
    }
1089072
public function asCollectionOf(IType $elementType, string $collectionClass = ITypedCollection::class)
    {
        $this->defineType(Type::collectionOf($elementType, $collectionClass));
    }