Return an entity of the aggregated type and set the initial
property.

@param array $data
@param array $config Extra configuation for instantiating the object

@return AnDomainEntityAbstract
435752
public function addNew($data = array(), $config = array())
    {
        $config = new AnConfig($config);
        $config['data'] = $data;
        $entity = $this->getRepository()->getEntity($config);
        $this->insert($entity);

        return $entity;
    }
1023312
public static function updateEntityFromArray($entity, array $data)
    {
        foreach ($data as $field => $value) {
            $method = 'set' . self::formatStringToMethodName($field);
            if (method_exists($entity, $method)) {
                $entity->$method($value);
            }
        }

        return $entity;
    }
899070
public function create($data)
    {
        $data = new AnConfig($data);

        $data->append(array(
            'owner' => $data->target ? $data->target : $data->subject,
        ));

        $data = AnConfig::unbox($data);

        return $this->getEntity(array('data' => $data));
    }
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;
	}
1221588
public function initFromArray(array $data) {

        $this->traitInitFromArray($data);

        $this->setOldestOutstanding((new OldestOutstandingPart())->initFromArray($data['oldest_outstanding']));

        return $this;

    }
1050401
public static function unserialize(array $config)
    {
        $configuration = new static;

        if (false !== ($clientConfiguration = unserialize($config['watched_files']))) {
            $configuration->set($clientConfiguration);
        }

        return $configuration;
    }
1008926
public static function deserialize(array $config)
    {
        if (isset($config['class']) && isset($config['config'])) {
            $config = $config['config'];
        }
        $instance = new self();
        $instance->loadConfig($config);
        return $instance;
    }
449673
public static function getInstance($config = array())
    {
        static $instance;

        if ($instance === null) {
            if (!$config instanceof AnConfig) {
                $config = new AnConfig($config);
            }

            $instance = new self($config);
        }

        return $instance;
    }
758354
protected function createXmlResponse(array $data, array $config)
    {
        if (! \is_null($root = $config['root'] ?? null)) {
            $data = $data[$root] ?? [];
        }

        if ($data instanceof Arrayable) {
            $data = $data->toArray();
        }

        $data = \array_map([$this, 'transformToArray'], $data);

        return function () use ($data, $config) {
            return ArrayToXml::convert($data, $config['document-root'] ?? $root);
        };
    }
206343
public function initFromArray(array $data) {

        $this->traitInitFromArray($data);

        if (!empty($data['details'])) {
            $this->setDetails((new LedgerDetailsPart())->initFromArray($data['details']));
        }

        return $this;

    }
803405
public function factory($type, array $config)
    {
        $this->setFactoryCreationOptions($type, $config);

        return $this->get($type, $config, false);
    }
180885
public static function createFromData(array $data)
    {
        if (!isset($data['type'])) {
            throw new DomainException(self::MSG_REQUIRED_TYPE);
        }

        if (!in_array($data['type'], self::allowedRejectionTypes(), true)) {
            throw new DomainException(self::MSG_UNSUPPORTED_TYPE);
        }

        return new self($data);
    }
768815
public static function configure(array $config)
    {
        if (!is_null(static::$instance)) {
            return static::$instance;
        }

        static::$config = $config;

        static::$session = Session::getInstance();

        return static::$instance = new Auth($config[$config['default']]);
    }
859583
private function createColumn(array $config)
    {
        $colType = isset($config['colType']) ? $config['colType'] : 'Select';
        if (class_exists($colType, true)) {
            $class = $colType;
        } elseif (class_exists('ZfcDatagrid\\Column\\'.$colType, true)) {
            $class = 'ZfcDatagrid\\Column\\'.$colType;
        } else {
            throw new \InvalidArgumentException(sprintf('Column type: "%s" not found!', $colType));
        }

        if ('ZfcDatagrid\\Column\\Select' == $class) {
            if (! isset($config['select']['column'])) {
                throw new \InvalidArgumentException(
                    'For "ZfcDatagrid\Column\Select" the option select[column] must be defined!'
                );
            }
            $table = isset($config['select']['table']) ? $config['select']['table'] : null;

            $instance = new $class($config['select']['column'], $table);
        } else {
            $instance = new $class();
        }

        foreach ($config as $key => $value) {
            $method = 'set'.ucfirst($key);
            if (method_exists($instance, $method)) {
                if (in_array($key, $this->specialMethods)) {
                    if (! is_array($value)) {
                        $value = [
                            $value,
                        ];
                    }
                    call_user_func_array([
                        $instance,
                        $method,
                    ], $value);
                } else {
                    call_user_func([
                        $instance,
                        $method,
                    ], $value);
                }
            }
        }

        return $instance;
    }
1125366
public static function fromData(array $data)
    {
        $reflection = new \ReflectionClass(static::class);
        $instance = $reflection->newInstanceWithoutConstructor();
        $instance->data = $data;
        $instance->jsonUnserialize($data);
        return $instance;
    }
69751
public function getEntity($config = array())
    {
        if ($this->getDescription()->isAbstract()) {
            throw new AnDomainRepositoryException('Can not instantiate an abstract entity '.$this->getDescription()->getEntityIdentifier());
        }

        $context = $this->getCommandContext();
        $context->append(array('data' => array()));
        $context->append($config);

        //force data to be stored by real name
        foreach ($context->data as $key => $value) {
            $property = $this->getDescription()->getProperty($key);
            if ($property) {
                unset($context->data[$key]);
                $context->data[$property->getName()] = $value;
            }
        }

        $entity = clone $this->getClone();
        $context->entity = $entity;
        $this->getCommandChain()->run('after.instantiate', $context);

        //set the entity data
        $data = AnConfig::unbox($context['data']);
        $entity->setData($data, AnDomain::ACCESS_PROTECTED);

        return $entity;
    }
697653
public function init(array $config) {
		if ($config) {
			foreach ($config as $key => $value) {
				$method = 'set' . ucfirst(camel_case($key));

				if (method_exists($this, $method)) {
					$this->$method($value);
				}
			}
		}

		return $this;
	}