Hydrate the object with data

@param  AbstractModel    $object
@param  array            $data
@return AbstractModel
@throws RuntimeException
194155
public function hydrate(AbstractModel $object, $data = [])
    {
        if (!empty($data)) {
            foreach ($data as $k => $v) {

                if (in_array($k, $object::$properties)) {

                    $method = $this->camelize(
                        sprintf('set_%s', $k)
                    );

                    if (!is_callable([$object, $method])) {
                        throw new RuntimeException(sprintf(
                            'Trying to call method "%s" on "%s" but it does not exist or is private.',
                            $method,
                            get_class($object)
                        ));
                    } else {
                        $object->$method($v);
                    }
                }
            }
        }

        return $object;
    }
319179
protected function doHydrate(array $data, $object)
    {
        $previousHydrationContext = $this->currentHydrationContext;
        $this->currentHydrationContext = new CurrentHydrationContext($data, $object);

        foreach ($this->metadata->getMappedFieldNames() as $mappedFieldName) {
            $defaultValue = $this->metadata->getFieldDefaultValue($mappedFieldName);

            if (null !== $defaultValue) {
                $this->resolveValue($defaultValue, $object);
                $this->memberAccessStrategy->setValue($defaultValue, $object, $mappedFieldName);   
            }
        }

        if (! $this->metadata->hasCustomHydrator()) {

            $this->executeMethods($object, $this->metadata->getPreHydrateListeners());

            foreach ($data as $originalFieldName => $value) {
                $mappedFieldName = $this->metadata->getMappedFieldName($originalFieldName);
                if (null === $mappedFieldName) {

                    //It's possible that a raw field name has no corresponding field name
                    //because a raw field can be a value object part.
                    continue;
                }

                if (! $this->metadata->hasSource($mappedFieldName)) {
                    //Classical hydration.
                    $this->walkHydration($mappedFieldName, $object, $value, $data);
                }
            }
        } else {
            list($customHydratorClass, $customHydrateMethod) = $this->metadata->getCustomHydratorInfo();
            $this->executeMethod($object, new ClassMetadata\Model\Method($customHydratorClass, $customHydrateMethod, [$data, $object]));
        }

        //DataSources hydration.
        foreach ($this->metadata->getFieldsWithDataSources() as $mappedFieldName) {

            if ($this->metadata->hasDataSource($mappedFieldName)) {//<= Is this test usefull ?
                $this->walkHydrationByDataSource($mappedFieldName, $object, false);
            }
        }

        //Providers hydration.
        foreach ($this->metadata->getFieldsWithProviders() as $mappedFieldName) {

            if ($this->metadata->hasProvider($mappedFieldName)) {//<= Is this test usefull ?
                $this->walkHydrationByProvider($mappedFieldName, $object, false);
            }
        }

        //Value objects hydration.
        foreach ($this->metadata->getFieldsWithValueObjects() as $mappedFieldName) {
            $this->walkValueObjectHydration($mappedFieldName, $object, $data);
        }

        $this->executeMethods($object, $this->metadata->getPostHydrateListeners());

        $this->currentHydrationContext = $previousHydrationContext;

        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);
    }
371640
public function hydrate(array $data, $object)
    {
        $object->setId(isset($data['e.id']) ? $data['e.id'] : $data['id']);
        $object->setName(isset($data['e.name']) ? $data['e.name'] : $data['name']);
        $object->setDefault(isset($data['e.isdefault']) ? $data['e.isdefault'] == 1 : $data['isdefault'] == 1);
        return $object;
    }
462788
public function hydrate(array $data, $object)
    {
        $size = getImageSize($data['tmp_name']);

        $object->setFileName($data['name'])
            ->setType($data['type'])
            ->setSize($data['size'])
            ->setTempName($data['tmp_name'])
            ->setWidth($size[0])
            ->setHeight($size[1])
            ->setMimeType($size[2])
            ->setError($data['error']);
        return $object;
    }
236822
public function hydrate(array $data, $object)
    {
        parent::hydrate($data, $object);
        $object->setEnvironment($object->getFact(NodeInterface::ENVIRONMENT_FACT));
        return $object;
    }
158051
public function hydrate( array $data, $object )
    {
        if ( $object instanceof MapperAwareInterface )
        {
            $object->setMapper( $this );
        }

        if ( $object instanceof Structure )
        {
            if ( ! empty( $data['cssFile'] ) && is_file( $data['cssFile'] ) )
            {
                $object->parseFile( $data['cssFile'] );
            }
            else if ( ! empty( $data['css'] ) )
            {
                $object->parseString( $data['css'] );
            }
        }
        else
        {
            if ( ! empty( $data['cssFile'] ) && is_file( $data['cssFile'] ) )
            {
                $object->css = file_get_contents( $data['cssFile'] );
            }
            else if ( ! empty( $data['css'] ) )
            {
                $object->css = (string) $data['css'];
            }
        }

        if ( array_key_exists( 'rootId', $data ) )
        {
            $object->rootId = $data['rootId'];
        }

        return $object;
    }
1355698
public function _beforeSave(AbstractModel $object)
    {

        $object->setUpdatedAt($this->date->gmtDate());
        
        if ($object->isObjectNew()) {
            $object->setCreatedAt($this->date->gmtDate());
        }

        return parent::_beforeSave($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;
    }
1289488
private static function getHydratorClosure($object)
    {
        if (!isset(self::$hydratorClosure)) {
            self::$hydratorClosure = function($object, array $data) {
                foreach ($data as $name => $value) {
                    $object->$name = $value;
                }
            };
        }

        $class = get_class($object);

        if (!isset(self::$hydratorClosureCache[$class])) {
            self::$hydratorClosureCache[$class] = \Closure::bind(self::$hydratorClosure, null, $class);
        }

        return self::$hydratorClosureCache[$class];
    }
1364013
public function hydrate(array $data, $object)
    {
        if (!$object instanceof News) {
            throw new \Exception('$object must be an instance of News');
        }

        return parent::hydrate($data, $object);
    }
511339
protected function hydrateObjectForm($object)
    {
        $data = array(
            "id" => $object->getId(),
            "visible" => (bool) $object->getVisible(),
            "code" => $object->getCode(),
            "title" => $object->getTitle(),
            "type" => $object->getType(),
            "entity" => $object->getEntity(),
            "serialized_columns" => $object->getSerializedColumns(),
            "serialized_condition" => $object->getSerializedCondition(),
            "index_engine_driver_configuration_id" => $object->getIndexEngineDriverConfigurationId(),
        );

        return $this->getUpdateForm($data);
    }
877810
public function hydrate(array $data, $object)
    {
        $object->setType($data['type'])
            ->setData($data['data'])
            ->setStore($data['store'])
            ->setDownload($data['download'])
            ->setOutputFilename($data['output_filename'])
            ->setCategory($data['category']);

        return $object;
    }
1059638
protected function hydrateObjectForm($object)
    {
        $data = array(
            'id'                => $object->getId(),
            'firstname'         => $object->getFirstname(),
            'lastname'          => $object->getLastname(),
            'login'             => $object->getLogin(),
            'profile'           => $object->getProfileId(),
            'locale'            => $object->getLocale(),
            'email'             => $object->getEmail()
        );

        // Setup the object form
        return $this->createForm(AdminForm::ADMINISTRATOR_MODIFICATION, "form", $data);
    }
568704
public function hydrate(array $data, $object)
    {
        if (isset($data['forge-name'])) {
            $object->setName($data['forge-name']);
        } elseif (isset($data['name'])) {
            $object->setName($data['name']);
        }
        if (isset($data['inherited'])) {
            $object->setInherited($data['inherited']);
        }
        if (isset($data['version'])) {
            $object->setVersion($data['version']);
        }
        if (isset($data['source'])) {
            $object->setSource($data['source']);
        }
        if (isset($data['project_page'])) {
            $object->setProjectPage($data['project_page']);
        }
        if (isset($data['issues_url'])) {
            $object->setIssuesUrl($data['issues_url']);
        }
        if (isset($data['author'])) {
            $object->setAuthor($data['author']);
        }
        if (isset($data['summary'])) {
            $object->setSummary($data['summary']);
        }
        if (isset($data['license'])) {
            $object->setLicense($data['license']);
        }
        return $object;
    }
915739
protected function hydrateObjectForm($object)
    {
        $data = [
            'id'          => $object->getId(),
            'code'        => $object->getCode(),
            'type'        => $object->getType(),
            'native'      => $object->getNative(),
            'by_module'   => $object->getByModule(),
            'block'       => $object->getBlock(),
            'active'      => $object->getActivate(),
            'locale'      => $object->getLocale(),
            'title'       => $object->getTitle(),
            'chapo'       => $object->getChapo(),
            'description' => $object->getDescription(),
        ];

        return $this->createForm(AdminForm::HOOK_MODIFICATION, 'form', $data);
    }
577391
public function hydrate(array $data, $object)
    {
        if (!$object instanceof ServerInfo) {
            throw new \Exception('$object must be an instance of ServerInfo');
        }

        return parent::hydrate($data, $object);
    }