Populates the associated objects of the given object.

@param DataObject $object
@param array $data
@param array $fixtures

@return DataObject
502701
public function populateObjects(DataObject $object, $data, $fixtures)
    {
        // Populate Objects:
        
        foreach ($data as $name => $value) {
            
            // Detect Object:
            
            if ($this->isObject($object, $name)) {
                
                // Trim Name:
                
                $name = ltrim($name, '->');
                
                // Populate Object:
                
                if ($subObject = $object->$name) {
                    
                    foreach ($value as $k => $v) {
                        $subObject->$k = $v;
                    }
                    
                    $subObject->write();
                    
                }
                
            }
            
        }
    }
721960
protected function runHandler($object, $data = null)
    {
        /** @var ITypedObject $object */

        $stagedForm = $this->form->getStagedForm();
        $knownData  = [IObjectAction::OBJECT_FIELD_NAME => $object];
        $stages     = $stagedForm->withSubmittedFirstStage($knownData);

        $form = StagedForm::begin(ObjectForm::build($this->dataSource)->withInitialValues($knownData));

        foreach ($stages->getAllStages() as $stage) {
            $currentStageForm = $stage->loadForm($knownData);

            $form->then($currentStageForm);
            $knownData += $currentStageForm->getInitialValues();
        }

        return $form->build();
    }
284773
public static function populateResponseData(IResponse $response, &$dataObject): void
    {
        foreach (array_keys($response->data()) as $key) {
            $method = 'set';
            $method .= ucfirst(Str::camel($key));
            if (!method_exists($dataObject, $method)) {
                continue;
            }

            $dataObject->{$method}($response->{$key});
        }
    }
32676
public function populateFromObject(
        ApiPopulatableInterface $object,
        array $ignore = []
    ) {
        if ($object instanceof Language) {
            $this->populate($object->toArray(), $ignore);
        }
    }
618252
public function populateOneRelation(DataObject $object, $field, $value)
    {
        // Trim Field ID:
        
        $field = $this->trimID($field);
        
        // Obtain Relation Class:
        
        if ($hasOneClass = $this->getSchema()->hasOneComponent($object, $field)) {
            
            // Define Relation:
            
            if ($this->isFile($hasOneClass)) {
                $object->{$field . 'ID'} = $this->processFile($object, $field, $value, $hasOneClass);
            } else {
                $object->{$field . 'ID'} = $this->processValue($value);
            }
            
            // Handle Polymorphic Relation:
            
            if ($this->isReference($value)) {
                
                list($class, $identifier) = $this->processTypedIdentifier($value);
                
                if ($hasOneClass === DataObject::class) {
                    $object->{$field . 'Class'} = $class;
                }
                
            }
            
        }
        
        // Answer Object:
        
        return $object;
    }
781974
protected function populate(AbstractResponse $object, array $data)
    {
        $reflect = new ReflectionClass($object);

        $properties = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);

        foreach ($properties as $property) {
            if (array_key_exists($property->name, $data)) {
                $object->{$property->name} = $this->getValueByAnnotatedType($property, $data[$property->name]);
            }
        }

        return $object;
    }
868111
private function update($object, array $data)
    {
        //only save when a change is detected
        if (!empty($data)) {
            $queryBuilder = $this->manager->getDriver()->getQueryBuilder();
            $primaryKey   = $this->getPrimaryKey();

            $this->manager->postPendingQuery(
                new PendingQuery(
                    $this,
                    PendingQuery::TYPE_UPDATE,
                    $queryBuilder
                        ->update($this->getTable())
                        ->values($queryBuilder->createPositionalParameter($data))
                        ->where(
                            $queryBuilder->expression()->eq(
                                $primaryKey,
                                $queryBuilder->createPositionalParameter(
                                    $this->getState($object)->getOriginalFieldData($primaryKey)
                                )
                            )
                        )
                )
            );
        }

        return $this->getPrimaryKeyValue($object);
    }
633329
public function populateDefaults(DataObject $object, $identifier, $data, $fixtures)
    {
        // Iterate Defaults:
        
        foreach ($this->getDefaults() as $name => $value) {
            
            // Is Value Callable?
            
            if (is_callable($value)) {
                $object->$name = $value($object, $data, $fixtures);
            } else {
                $object->$name = $value;
            }
            
        }
        
        // Answer Object:
        
        return $object;
    }
99457
public function hydrate(array $data, $object)
    {
        $object->setId($data['id']);
        $object->setLogin($data['login']);
        $object->setName($data['name']);
        $object->setEmail($data['email']);
        $object->setRole($data['role']);
        return $object;
    }
1115454
public function populate(array $data) {
        foreach ($data as $property => $value) {
            $property = \Util::_toCamel($property);
            $method = 'set' . ucfirst($property);
            if (method_exists($this, $method)) {
                $this->$method($value);
            }
            elseif (property_exists($this, $property)) {
                $this->$property = $value;
            }
        }

        return $this;
    }
1318528
public function populate(array $data)
    {
        foreach ($data as $property => $value) {
            if (property_exists($this, $property)) {
                $this->{$property} = $value;
            }
        }
        return $this;
    }
71928
public function populateManyRelation(DataObject $object, $field, $value)
    {
        // Initialise:
        
        $ids = [];
        
        // Process Value as Array:
        
        if ($value = $this->processValueAsArray($value)) {
            
            // Is Value an Associative Array?
            
            $isAssoc = ArrayLib::is_associative($value);
            
            // Output Verbose Message:
            
            $this->verboseMessage(sprintf('%s has an %s array value', $field, ($isAssoc ? 'associative' : 'indexed')));
            
            // Handle Array Values:
            
            if ($isAssoc) {
                
                foreach ($value as $k => $v) {
                    
                    if ($this->isTypedIdentifier($k)) {
                        
                        // Process Typed Identifier:
                        
                        list($class, $identifier) = $this->processTypedIdentifier($k);
                        
                        // Obtain Remote Join Field:
                        
                        if ($join = $this->getSchema()->getRemoteJoinField($object, $field)) {
                            
                            // Define Item Data:
                            
                            $data = (array) $v;
                            
                            if (!isset($data[$join])) {
                                $data[$join] = $object->ID;
                            }
                            
                            // Define Item Filter:
                            
                            $filter = [$join => $data[$join]];
                            
                            // Create Item Object:
                            
                            $this->getFactory()->createObject($class, $identifier, $data, $filter);
                            
                        }
                        
                    }
                    
                }
                
            } else {
                
                // Obtain ID List:
                
                foreach ($value as $k => $v) {
                    $ids[] = $this->processValue($v);
                }
                
                // Populate Relation:
                
                $this->populateManyRelationByIDs($object, $field, $ids);
                
            }
            
        }
        
        // Answer Object:
        
        return $object;
    }
626993
public function hydrate(array $data, $object)
    {
        $this->prepare($object);

        if ($this->byValue) {
            return $this->hydrateByValue($data, $object);
        }

        return $this->hydrateByReference($data, $object);
    }
685571
public function map($object, $data)
    {
        $object
            ->setProductId($data['OXID'])
            ->setRatingAverage($data['OXRATING'])
            ->setRatingCount($data['OXRATINGCNT']);

        return $object;
    }
1360566
protected function runHandler($object, $data = null)
    {
        /** @var ITypedObject $object */
        /** @var ArrayDataObject $data */
        $input = $data->getArray();

        if ($this->dataSource instanceof IValueObjectCollection) {
            /** @var IValueObject $object */
            /** @var IValueObject $newObject */
            $newObject = $this->form->createNewObjectFromInput($input);

            $this->form->invokeBeforeSubmitCallbacks($newObject, $input);
            $this->form->bindToObject($newObject, $input);
            $this->form->invokeOnSubmitCallbacks($newObject, $input);

            $this->dataSource->update($object, $newObject);

            $this->form->invokeOnSaveCallbacks($object, $input);

            return $newObject;
        } else {
            $this->form->invokeBeforeSubmitCallbacks($object, $input);
            $this->form->bindToObject($object, $input);
            $this->form->invokeOnSubmitCallbacks($object, $input);

            $this->dataSource->save($object);

            $this->form->invokeOnSaveCallbacks($object, $input);

            return $object;
        }
    }
349751
public function populateField(DataObject $object, $name, $value)
    {
        // Detect Value Type:
        
        if (is_array($value) && $object->hasField($name)) {
            
            // Handle Array Value:
            
            if ($object->dbObject($name) instanceof DBComposite) {
                
                // Handle Composite Field:
                
                foreach ($value as $k => $v) {
                    $object->dbObject($name)->setField($k, $this->processValue($v));
                }
                
            } else {
                
                // Handle Regular Field (JSON-encode):
                
                $object->setField($name, $this->processArray($value, true));
                
            }
            
        } else {
            
            // Handle Regular Value:
            
            $object->setField($name, $this->processValue($value));
            
        }
    }
977255
protected function doMerge($object, array $dataObject, array $mapping = [])
    {
        if (count($mapping)) {
            foreach ($mapping as $field => $params) {
                if (is_string($params)) {
                    // Tries to decode if params is a string, so we can have a mapping information stringified in JSON
                    $params = json_decode($params, true);
                }
                if (!is_array($params)) {
                    // Allows anything to be transformed into an array
                    // If we used json_decode, "null" will be returned and then it'll become an empty array
                    // Although $params should be either "1", "true" or an array, even empty
                    $params = [];
                }
                if (array_key_exists($field, $dataObject)) {
                    $this->mergeField($field, $object, $dataObject[$field], $params);
                } else {
                    throw new \InvalidArgumentException(
                        sprintf(
                            'If you want to specify "%s" as an mergeable field, then you must have to set it in your data object.',
                            $field
                        )
                    );
                }
            }
        } else {
            foreach ($dataObject as $field => $value) {
                $this->mergeField($field, $object, $value);
            }
        }

        return $object;
    }