Internal function to fill the parents.

@param mixed    $entity
@param array    $path
@param object[] $parents
350881
protected function insertParents($entity, array $path, array $parents)
    {
        $propertyName = reset($path);
        $propertyValue = Core::get()->getObjectService()->getObjectProperty($entity, $propertyName);

        if (1 === count($path)) {
            if (is_object($propertyValue)
                && Core::get()->getParentsUtility()->classUsesParentsTrait($propertyValue)
            ) {
                /** @var ParentsTrait $propertyValue */
                $propertyValue->attachParents($this->filterParents($parents));
            }
        } else {
            if (is_object($propertyValue)) {
                $parents[] = $propertyValue;
            }

            array_shift($path);
            $this->insertParents($propertyValue, $path, $parents);
        }
    }
1100215
public function insert($entity)
    {
        $entityId = $this->entityRegistry->getEntityId($entity);

        if (empty($entityId)) {
            $id = 0;

            foreach ($this->gateway->getAll($this->tableName) as $row) {
                $id = max($id, $row['id']);
            }

            $this->entityRegistry->setEntityId($entity, $id + 1);
        }

        $this->gateway->insert($this->tableName, $this->builder->reduce($entity));
        $this->builder->resolve($entity);
    }
1200043
protected function insert($entity)
    {
        // If this entity was a child of aggregate roots, then call its methods to set the aggregate root Id
        $this->entityRegistry->runAggregateRootCallbacks($entity);
        $className = $this->entityRegistry->getClassName($entity);
        $dataMapper = $this->getDataMapper($className);
        $idGenerator = $this->idGeneratorRegistry->getIdGenerator($className);

        if ($idGenerator === null) {
            $dataMapper->add($entity);
        } else {
            if ($idGenerator instanceof SequenceIdGenerator) {
                $idGenerator->setConnection($this->connection);
            }

            if ($idGenerator->isPostInsert()) {
                $dataMapper->add($entity);
                $this->idAccessorRegistry->setEntityId(
                    $entity,
                    $idGenerator->generate($entity)
                );
            } else {
                $this->idAccessorRegistry->setEntityId(
                    $entity,
                    $idGenerator->generate($entity)
                );
                $dataMapper->add($entity);
            }
        }

        $this->entityRegistry->registerEntity($entity);
    }
1344438
public function fillData($entity,
        ArrayHash $values)
    {
        $properties = $this->getEntityProperties($entity);
        foreach ($properties as $property) {
            if (array_key_exists($property, $values)) {
                // You may want to process Collection property elsewhere
                if (!$entity->$property instanceof Collection) {
                    $entity->$property = $values->$property;
                }
            }
        }
        $entity->modifiedOn = new DateTime();
        return $entity;
    }
325063
private function buildTree(array $parentEntities)
    {
        foreach ($parentEntities as $parentEntity) {
            if (isset($this->entityOverride[$parentEntity])) {
                $parentEntity = $this->entityOverride[$parentEntity];
            }

            $parentMeta = $this->metadata[$parentEntity];
            $parentConfiguration = $parentMeta->getConfiguration();

            foreach ($parentConfiguration['children'] as $key => $childEntity) {
                if (isset($this->entityOverride[$childEntity])) {
                    $childEntity = $this->entityOverride[$childEntity];
                }
                if (!isset($this->metadata[$childEntity])) {
                    unset($parentConfiguration['children'][$key]);

                    continue;
                }

                $childMeta = $this->metadata[$childEntity];
                $associated = false;

                foreach ($childMeta->getMappings() as $property => $mapping) {
                    if (!$childMeta->isAssociation($property)
                        || ($mapping['targetEntity'] !== $parentEntity && !in_array($mapping['targetEntity'], class_parents($parentEntity)))
                    ) {
                        continue;
                    }

                    $childMeta->setParent(new AssociatedMetadata($property, $parentMeta));
                    $parentMeta->addChild(new AssociatedMetadata($property, $childMeta));
                    $associated = true;

                    if (null !== $mapping['inversedBy']) {
                        break;
                    }
                }
                if (!$associated) {
                    throw new MetadataException(
                        sprintf('Entity "%s" is not associated with entity "%s".', $childEntity, $parentEntity)
                    );
                }
            }

            $this->buildTree($parentConfiguration['children']);
        }
    }
1129215
public function rebuildTree($entityClass = '',
        $parentEntity)
    {
        if ($entityClass === '') {
            throw new Exception('messages.error.classNameNotProvided');
        }
        if ($parentEntity === null) {
            throw new Exception('messages.error.cantRemakeTree');
        }
        $dqlLft = '
                UPDATE ' . $entityClass . ' a
                SET a.lft = a.lft + 2
                WHERE a.lft > ' . $parentEntity->rgt . '
            ';
        $q = $this->query($dqlLft);
        $q->execute();

        $dqlRgt = '
                UPDATE ' . $entityClass . ' a
                SET a.rgt = a.rgt + 2
                WHERE a.rgt >= ' . $parentEntity->rgt . '
            ';
        $q2 = $this->query($dqlRgt);
        $q2->execute();
    }
791540
private function handleEntity($entity)
    {
        if (null !== $page = $this->findRelatedPage($entity)) {
            if (null === $page->getId()) {
                return;
            }
            if (!$this->pages->contains($page)) {
                $this->pages->add($page);
            }
        }
    }
282742
public function insert($entity)
    {
        $eloquentModel = $this->getEloquentModel($entity);

        $this->updateRelations($eloquentModel, 'insert');

        $eloquentModel->save();

        $eloquentModel->afterSaving($entity, 'insert');
    }
570359
public function setParent(\Neobazaar\Entity\Document $parent = null)
    {
        $this->parent = $parent;
    
        return $this;
    }
363168
public function moveAfter($entity)
    {
        if ($this->parent_id == $entity->parent_id) {
            $this->position = $entity->position + 1;
            $this->save();
        } else {
            $this->moveTo($entity->position + 1, $entity->parent_id);
        }
    }
728050
function parent($new = null, $return_entity = false)
    {
        if (isset($new)){
            if ($new instanceof Entity){
                $this->_parent = $new;
                $new = $new->uri();
            }else{
                $this->_parent = null; // for reloading
            }
            if ($new != $this->_attributes['parent']){
                $this->change('parent', $new);
                $this->change('order', Entity::MAX_ORDER);
                $this->change('uri', $new.'/'.$this->_attributes['name']);
            }
        }
        if ($return_entity){
            if (!isset($this->_parent)){
                if (isset($this->_attributes['parent'])){
                    $this->_parent = Data::read($this->_attributes['parent']);
                }else{
                    $this->_parent = false;
                }
            }
            return $this->_parent;
        }
        return $this->_attributes['parent'];
    }
812507
public void setParents(java.util.Collection<Parent> parents) {
        if (parents == null) {
            this.parents = null;
            return;
        }

        this.parents = new java.util.ArrayList<Parent>(parents);
    }
463254
public function setParent(\Haven\PersonaBundle\Entity\Enterprise $parent = null) {
        $this->parent = $parent;

        return $this;
    }
592089
public static function fill(array $data, COCEntity &$entity)
    {
        $vars = get_object_vars($entity);
        foreach ($vars as $var => $_) {
            if (array_key_exists($var, $data)) {
                $entity->{$var} = $data[$var];
            }
        }
    }
1221386
public function load($entities, $depth = 1)
    {
        if (!\is_array($entities) && !$entities instanceof \Traversable) {
            throw new \InvalidArgumentException(self::E_MSG);
        }

        $entitiesByValueClassByIds = $this->sortEntitiesByValueClass($entities);
        foreach ($entitiesByValueClassByIds as $valueClass => $entitiesById) {
            $this->loadEntityValues($valueClass, $entitiesById);
        }

        $this->loadRelatedEntities($entities, $depth);
    }
1143355
public function moveBefore($entity)
    {
        if ($this->parent_id == $entity->parent_id) {
            $this->position = $entity->position - 1;
            $this->save();
        } else {
            $this->moveTo($entity->position - 1, $entity->parent_id);
        }
    }
327047
private function performFindAndReplaceInFile(
        string $path
    ): void {
        $this->findAndReplaceHelper->findReplace(
            'use ' . RelationsGenerator::FIND_ENTITIES_NAMESPACE . '\\' . RelationsGenerator::FIND_ENTITY_NAME,
            "use {$this->entityFqn}",
            $path
        );
        $this->findAndReplaceHelper->findReplace(
            'use ' .
            RelationsGenerator::FIND_ENTITY_INTERFACE_NAMESPACE .
            '\\' .
            RelationsGenerator::FIND_ENTITY_INTERFACE_NAME,
            "use {$this->entityInterfaceFqn}",
            $path
        );
        $this->findAndReplaceHelper->findReplaceRegex(
            '%use(.+?)Relations\\\TemplateEntity(.+?);%',
            'use ${1}Relations\\' . $this->singularNamespace . '${2};',
            $path
        );
        $this->findAndReplaceHelper->findReplaceRegex(
            '%use(.+?)Relations\\\TemplateEntity(.+?);%',
            'use ${1}Relations\\' . $this->pluralNamespace . '${2};',
            $path
        );
        $this->findAndReplaceHelper->findReplaceRegex(
            '%(Has|Reciprocates)(Required|)TemplateEntity%',
            '${1}${2}' . $this->singularNamespacedName,
            $path
        );
        $this->findAndReplaceHelper->findReplaceRegex(
            '%(Has|Reciprocates)(Required|)TemplateEntities%',
            '${1}${2}' . $this->pluralNamespacedName,
            $path
        );
        $this->findAndReplaceHelper->findReplace(
            RelationsGenerator::FIND_ENTITY_INTERFACE_NAME,
            $this->namespaceHelper->basename($this->entityInterfaceFqn),
            $path
        );
        $this->findAndReplaceHelper->replaceName($this->singularNamespacedName, $path);
        $this->findAndReplaceHelper->replacePluralName($this->pluralNamespacedName, $path);
        $this->findAndReplaceHelper->replaceProjectNamespace($this->projectRootNamespace, $path);
    }