Hydrate array data to an object based on the configuration given

@param array $data
@param ByConfigBuilder $config

@return object | \ArrayIterator on a collection
7490
public static function hydrate(array $data, ByConfigBuilder $config)
    {
        // When entity is not available. Only use the collection to set the data
        if ($config->getEntity() === false) {
            return $config->getCollectionEntity($data);
        }

        // When there is no collection specified. Make sure there will be an array to iterate through
        if ($config->isCollection() === false) {
            $data = array($data);
        }

        $rows = array();

        // Loop through the data
        foreach ($data as $index => $row) {
            $rows[$index] = $entity = $config->getEntity();

            foreach ($row as $field => $value) {
                // Skip field if not defined in the configuration
                if ($config->hasField($field) === false) {
                    $catchAll = $config->getCatchAllSetter();

                    if ($catchAll !== null) {
                        call_user_func(array($entity, $catchAll), $field, $value);
                    }

                    continue;
                }

                $callable = array($entity, $config->getSetter($field));

                if ($config->isInclude($field) === true) {
                    if (is_array($value) === false) {
                        throw new Exception\HydrateFailed(sprintf(static::$exceptions[1], $field, gettype($value)));
                    }

                    $value = static::hydrate($value, $config->getInclude($field));
                } else if ($config->getFormatter($field) !== null) {
                    $value = call_user_func($config->getFormatter($field), $value);
                }

                // Add the value
                call_user_func($callable, $value);
            }
        }

        return ($config->isCollection() === true) ? $config->getCollectionEntity($rows) : $entity;
    }
603802
public function load(array $config = [])
    {
        $this->config = array_replace_recursive($this->config, $config);

        $this->enviroment();
        $this->errors();
        $this->templates();
        $this->orm();
        $this->router();

        return $this;
    }
971054
public function hydrate(array $data): void
    {
        if (!$data) {
            return;
        }

        if ($this->hydrationProperties === null || $this->hydrationSetters === null) {
            $reflection = new \ReflectionClass($this);
            $this->hydrationProperties = array_map(function ($v) {
                return $v->name;
            }, $reflection->getProperties(\ReflectionProperty::IS_PUBLIC));

            $this->hydrationSetters = array_filter(array_map(function ($v) {
                return strpos($v->name, 'set') === 0 ? $v->name : null;
            }, $reflection->getMethods(\ReflectionMethod::IS_PUBLIC)));
        }

        $camelCaseConvert = function ($v) {
            if (strpos($v, '_') === false) {
                return $v;
            }

            $v = explode('_', $v);

            $first = array_shift($v);
            $v = array_map('ucfirst', $v);

            return $first . implode('', $v);
        };

        foreach ($data as $key => $value) {
            if (in_array($key, $this->hydrationProperties, true)) {
                $this->{$key} = $value;
            } else {
                $camelCaseKey = $camelCaseConvert($key);
                $setter = 'set' . ucfirst($camelCaseKey);

                if ($camelCaseKey !== $key && in_array($camelCaseKey, $this->hydrationProperties, true)) {
                    $this->{$camelCaseKey} = $value;
                } elseif (in_array($setter, $this->hydrationSetters, true)) {
                    $this->$setter($value);
                } else {
                    throw new \OutOfBoundsException(sprintf(
                        'Invalid attribute provided "%s"',
                        $key
                    ));
                }
            }
        }
    }
174152
public function hydrate(array $data, $object)
    {
        foreach ($data as $name => $value) {
            $property = StringUtil::camel($name);
            if (property_exists($object, $property)) {
                $object->{$property} = $value;
            }
        }

        return $object;
    }
214019
public function hydrate(array $data, $object)
    {
        $object->setId($this->getData('id', $data));
        $createdAt = $this->getData('created_at', $data);
        $object->setCreatedAt(isset($createdAt) ? new \DateTime($createdAt) : null);
        $object->setCreatedBy($this->getData('created_by', $data));
        $object->setComment($this->getData('comment', $data));
        return $object;
    }
133469
public function hydrate( array $data, $structure )
    {
        if ( $structure instanceof Structure\ProxyBase )
        {
            if ( isset( $data['tags'] ) && is_string( $data['tags'] ) )
            {
                $data['tags'] = explode( static::TAG_SEPARATOR, $data['tags'] );
            }

            if ( isset( $data['tagIds'] ) && is_string( $data['tagIds'] ) )
            {
                $data['tagIds'] = explode( static::TAG_SEPARATOR, $data['tagIds'] );
            }

            if ( isset( $data['localeTags'] ) && is_string( $data['localeTags'] ) )
            {
                $data['localeTags'] = explode( static::TAG_SEPARATOR, $data['localeTags'] );
            }

            if ( isset( $data['proxyData'] ) )
            {
                $proxyData = $data['proxyData'] ?: array();
                unset( $data['proxyData'] );

                if ( is_string( $proxyData ) )
                {
                    $proxyData = $this->parseProxyData( $proxyData );
                }

                if ( is_array( $proxyData ) )
                {
                    $proxyData = array_merge( $data, $proxyData );
                }

                foreach ( static::$columns as $column => $type )
                {
                    unset( $proxyData[$column] );
                }
            }
            else
            {
                $proxyData = $data;
            }

            $proxyData['proxyBase'] = parent::hydrate( $data, $structure );
            $proxyData['type']      = $proxyData['proxyBase']->type;

            return $this->structureFactory
                        ->factory( $proxyData );
        }

        return parent::hydrate( $data, $structure );
    }
1097691
public function hydrate(array $data, $object)
    {
        foreach ($data as $key => $value) {

            $hydrateName = $this->hydrateName($key);

            if ($object->has($hydrateName)) {
                $method = 'set' . ucfirst($hydrateName);
                $value = $this->hydrateValue($hydrateName, $value, $data);
                $object->$method($value);
            }
        }

        return $object;
    }
630292
public function process(array $data, array $config)
	{
		// Intersect the data given the with the data keys provided.
		$specifiedData = array_intersect_key($data, array_flip(array_keys($config)));

		// Validate and set our errors if they exist.
		$this->errorPayload = $this->validator->validate($specifiedData, $config);

		// Return sanitized data if no validation errors exist.
		if($this->errorPayload->getStatus() == Payload::STATUS_VALID)
		{
			return new Payload($specifiedData, Payload::STATUS_VALID);
		}

		return $this->errorPayload;
	}
1132006
public function findOrAddNew($data = array(), $config = array())
    {
        $entity = $this->find($data);

        if (!$entity) {
            $entity = $this->addNew($data, $config);
        }

        return $entity;
    }
855137
public static function create(array $config = [])
    {
        $container = new Container();

        foreach (self::$booleanSetters as $key => $method) {
            if (isset($config[$key])) {
                $container->$method((bool) $config[$key]);
            }
        }

        foreach (self::$arraySetters as $key => $method) {
            if (isset($config[$key]) && is_array($config[$key])) {
                foreach ($config[$key] as $name => $value) {
                    $container->$method($name, $value);
                }
            }
        }

        if (isset($config[Container::CONFIG_ENTRIES]) && is_array($config[Container::CONFIG_ENTRIES])) {
            self::createEntries($container, $config[Container::CONFIG_ENTRIES]);
        }

        return $container;
    }
671390
public static function createFromConfig(array $config)
    {
        $manager = static::createEmptyFromConfig($config);

        $manager->addCollection(new CssCollection)
                ->addCollection(new JavascriptCollection);

        return $manager;
       
    }
1012950
public function findOrAddNew($data = array(), $config = array())
    {
        $target = $this->getRepository()->find($data);

        if (!$target) {
            $target = $this->addNew($data, $config);
        } else {
            $this->insert($target, $config);
        }

        return $target;
    }
1234909
protected function buildColumns(array $config)
    {
        $columns = [];

        foreach (isset($config['columns']) ? $config['columns'] : [] as $name => $column) {
            $column = $this->buildColumn(array_merge(['name' => $name], $column), $config);
            $columns[$column->getName()] = $column;
        }

        return $columns;
    }
214501
public function buildPDO(array $config=null) {
		if(!$config)
			$config = $this->config;
		$driver = $config['driver'];
		$user = isset($config['user']) ? $config['user']:'root';
		$password = isset($config['password']) ? $config['password']:'';
		$database = isset($config['database']) ? $config['database']:null;

		switch($driver) {
			case 'pgsql':
				$parameters = 'pgsql:host='.$config['host'].(isset($config['port']) ? ' port='.$config['port']:'').($database ? ' dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password);
				break;
			case 'mssql':
				$parameters = 'mssql:host='.$config['host'].($database ? ';dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password);
				break;
			case 'sqlite':
				$pdo = $this->pdo = new \PDO('sqlite:'.$database);
	
				require_once __DIR__.'/sqlite_functions.php';

				break;
			default:
				$parameters = 'mysql:host='.$config['host'].(isset($config['port']) ? ';port='.$config['port']:'').($database ? ';dbname='.$database:'');
				$this->pdo = new \PDO($parameters, $user, $password, [\PDO::MYSQL_ATTR_FOUND_ROWS => true, \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
		}
		$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
	}
747523
public static function hydrate(array $data)
    {
        return new self(
            $data['token'],
            $data['table'],
            KeySet::fromArray($data['keySet']),
            $data['columns'],
            $data['options']
        );
    }
63130
public function hydrate(array $items)
    {
        if (!$instance = $this->newModelInstance()) {
            return $items;
        }

        $models = array_map(function ($item) use ($instance) {
            return $instance->newFromBuilder($item);
        }, $items);

        if (!empty($this->with)) {
            $instance
                ->newQuery()
                ->setEagerLoads($this->eagerLoads())
                ->eagerLoadRelations($models);
        }

        return $models;
    }
136957
public function loadFromArray(array $config)
    {
        if (isset($config['domains'])) {
            $this->loadDomainConfiguration($config);
        }

        if (isset($config['general'])) {
            $general = $config['general'];
            $generalConfig = $this->getParsedConfig(
                $general,
                $this->config,
                $this->yamlConfigMap,
                []
            );
            $this->setCache(CacheFactory::get($generalConfig['cacheType'], $generalConfig['cacheOptions']));
            unset($generalConfig['cacheType']);
            unset($generalConfig['cacheOptions']);
            $this->setParsedConfig($generalConfig);
        }

        return $this;
    }