populate

@param array $data
@param array $ignore

@return void
189663
public function populate(array $data, array $ignore = ['createdByUserId', 'createdDate', 'createdReason'])
    {
        if (isset($data['site']) && $data['site'] instanceof Site
            && !in_array(
                'site',
                $ignore
            )
        ) {
            $this->setSite($data['site']);
        }

        if (isset($data['name']) && !in_array('name', $ignore)) {
            $this->setName($data['name']);
        }

        // @bc support
        if (isset($data['pageId']) && !in_array('pageId', $ignore)) {
            $this->setPageId($data['pageId']);
        }

        if (isset($data['pageTitle']) && !in_array('pageTitle', $ignore)) {
            $this->setPageTitle($data['pageTitle']);
        }

        if (isset($data['pageType']) && !in_array('pageType', $ignore)) {
            $this->setPageType($data['pageType']);
        }

        if (isset($data['description']) && !in_array('description', $ignore)) {
            $this->setDescription($data['description']);
        }

        if (isset($data['keywords']) && !in_array('keywords', $ignore)) {
            $this->setKeywords($data['keywords']);
        }

        if (isset($data['author']) && !in_array('author', $ignore)) {
            $this->setAuthor($data['author']);
        }

        if (isset($data['lastPublished'])
            && $data['lastPublished'] instanceof \DateTime
            && !in_array('lastPublished', $ignore)
        ) {
            $this->setLastPublished($data['lastPublished']);
        }

        if (isset($data['createdDate']) && $data['createdDate'] instanceof \DateTime
            && !in_array('createdDate', $ignore)
        ) {
            $this->setLastPublished($data['createdDate']);
        }

        if (isset($data['pageLayout']) && !in_array('pageLayout', $ignore)) {
            $this->setPageLayout($data['pageLayout']);
        }

        if (isset($data['siteLayoutOverride'])
            && !in_array(
                'siteLayoutOverride',
                $ignore
            )
        ) {
            $this->setSiteLayoutOverride($data['siteLayoutOverride']);
        }

        $parent = null;

        if (isset($data['parent']) && !in_array('parent', $ignore)) {
            $parent = $data['parent'];
        }

        if ($parent instanceof Page) {
            $this->setParent($parent);
        }
    }
877235
public function toArray($ignore = [])
    {
        $data = parent::toArray($ignore);

        if (!in_array('iso639_1', $ignore)) {
            $data['iso639_1'] = $this->getIso6391();
        }
        if (!in_array('iso639_2b', $ignore)) {
            $data['iso639_2b'] = $this->getIso6392b();
        }
        if (!in_array('iso639_2t', $ignore)) {
            $data['iso639_2t'] = $this->getIso6392t();
        }

        return $data;
    }
397875
public function populate($data = array())
    {
        $this->pageId = (isset($data['pageId'])) ? $data['pageId'] : null;
        $this->pageName = (isset($data['pageName'])) ? $data['pageName'] : null;
        $this->pageLink = (isset($data['pageLink'])) ? $data['pageLink'] : null;

    }
1153987
public function toArray($ignoreEmpty = false)
    {
        if (!$ignoreEmpty) {
            return $this->data;
        }

        return array_filter(
            $this->data,
            function ($value) {
                return !empty($value);
            }
        );
    }
304500
public function setInsert($table, $ignore = false)
	{
		$this->insert = $table;
		$this->ignore = $ignore;
	}
316320
public function populate($data = array())
    {
        if (isset($data['title']) && $data['title'] !== null) {
            $this->title = $data['title'];
        }

        if (isset($data['identifier']) && $data['identifier'] !== null) {
            $this->identifier = $data['identifier'];
        }

        if (isset($data['active']) && $data['active'] !== null) {
            $this->active = $data['active'];
        }

        if (isset($data['picto']) && $data['picto'] !== null) {
            $this->picto = $data['picto'];
        }
    }
782976
public function init(array $data = [])
    {
        foreach ($data as $key => $value) {
            $key = $this->getPreparedKey($key);
            $method = 'set' . str_replace(' ', '', $key);

            if (method_exists($this, $method)) {
                $this->{$method}($value);
            }
        }
    }
529576
public function fillFromArray(array $data)
	{
		$data = $data + array(
				'style' 		=> null,
				'align' 		=> null,
				'alternate_text' 	=> null,
				'title' 		=> null,
				'description' 	=> null,

				'size_width' 	=> null,
				'size_name' 	=> null,
				'crop_top' 		=> null,
				'crop_left' 	=> null,
				'crop_width' 	=> null,
				'crop_height' 	=> null,

				'size_height' 	=> null,
			);

		$this->imageId = $data['id'];
		$this->align = $data['align'];
		$this->style = $data['style'];
		$this->alternateText = $data['alternate_text'];
		$this->title = $data['title'];
		$this->description = $data['description'];

		$this->sizeName = $data['size_name'];

		$this->setWidth($data['size_width']);
		$this->setHeight($data['size_height']);
		$this->setCropTop($data['crop_top']);
		$this->setCropLeft($data['crop_left']);
		$this->setCropWidth($data['crop_width']);
		$this->setCropHeight($data['crop_height']);
	}
533134
public function addUserData(array $data = [], $reset = false, $override = false) {
        if ($data && is_array($data)) {
            if ($override) {
                $data = array_diff_key($data, $_REQUEST);
            }
            if ($reset) {
                $this->userData = $data;
            } else {
                $this->userData = array_merge($this->userData, $data);
            }
        }
    }
591156
public function populate(array $data, array $ignore = ['createdByUserId', 'createdDate', 'createdReason'])
    {
        if (!empty($data['siteId']) && !in_array('siteId', $ignore)) {
            $this->setSiteId($data['siteId']);
        }

        // Domain
        if (!empty($data['domain']) && $data['domain'] instanceof Domain
            && !in_array('domain', $ignore)
        ) {
            $this->setDomain($data['domain']);
            unset($data['domain']);
        }

        if (!empty($data['domain']) && empty($data['createdByUserId'])) {
            throw new TrackingException('Populating new domain requires createdByUserId');
        }

        if (!empty($data['domain']) && is_array($data['domain'])
            && !in_array('domain', $ignore)
        ) {
            // @todo This is dangerous
            $domain = new Domain(
                $data['createdByUserId'],
                'New domain on populate in ' . get_class($this)
            );
            $domain->populate($data['domain']);
            $this->setDomain($domain);
        }

        if (!empty($data['theme']) && !in_array('theme', $ignore)) {
            $this->setTheme($data['theme']);
        }
        if (!empty($data['siteLayout']) && !in_array('siteLayout', $ignore)) {
            $this->setSiteLayout($data['siteLayout']);
        }
        if (!empty($data['siteTitle']) && !in_array('siteTitle', $ignore)) {
            $this->setSiteTitle($data['siteTitle']);
        }

        // Language
        if (!empty($data['language']) && $data['language'] instanceof Language
            && !in_array('language', $ignore)
        ) {
            $this->setLanguage($data['language']);
            unset($data['language']);
        }

        if (!empty($data['language']) && empty($data['createdByUserId'])) {
            throw new TrackingException('Populating new language requires createdByUserId');
        }

        if (!empty($data['language']) && is_array($data['language'])
            && !in_array(
                'language',
                $ignore
            )
        ) {
            // @todo This is dangerous
            $language = new Language(
                $data['createdByUserId'],
                'New language on populate in ' . get_class($this)
            );
            $language->populate($data['language']);
            $this->setLanguage($language);
        }

        // Country
        if (!empty($data['country']) && $data['country'] instanceof Country
            && !in_array('country', $ignore)
        ) {
            $this->setCountry($data['country']);
            unset($data['country']);
        }

        if (!empty($data['country']) && empty($data['createdByUserId'])) {
            throw new TrackingException('Populating new country requires createdByUserId');
        }

        if (!empty($data['country']) && is_array($data['country'])
            && !in_array(
                'country',
                $ignore
            )
        ) {
            // @todo This is dangerous
            $country = new Country(
                $data['createdByUserId'],
                'New country on populate in ' . get_class($this)
            );
            $country->populate($data['country']);
            $this->setCountry($country);
        }
        if (!empty($data['status']) && !in_array('status', $ignore)) {
            $this->setStatus($data['status']);
        }
        if (!empty($data['favIcon']) && !in_array('favIcon', $ignore)) {
            $this->setFavIcon($data['favIcon']);
        }
        if (!empty($data['loginPage']) && !in_array('loginPage', $ignore)) {
            $this->setLoginPage($data['loginPage']);
        }
        if (!empty($data['notAuthorizedPage'])
            && !in_array(
                'notAuthorizedPage',
                $ignore
            )
        ) {
            $this->setNotAuthorizedPage($data['notAuthorizedPage']);
        }
        if (!empty($data['notFoundPage']) && !in_array('notFoundPage', $ignore)) {
            $this->setNotFoundPage($data['notFoundPage']);
        }
        if (!empty($data['supportedPageTypes'])
            && !in_array(
                'supportedPageTypes',
                $ignore
            )
        ) {
            $this->setSupportedPageTypes($data['supportedPageTypes']);
        }
    }
208324
public function fill($data)
    {
        if ($this->data) {
            throw new Exception('Trying to feel not empty context');
        }
        
        $this->data = $data;
        $this->version++;
    }
1235518
public function fill(array $data)
    {
        foreach ($data as $column => $value) {
            $this->__set($column, $value);
        }
        return $this;
    }
504101
public function toArray(
        $ignore = ['additionalDomains', 'domainValidator', 'site']
    ) {
        $data = parent::toArray($ignore);

        if (!in_array('siteId', $ignore)) {
            $data['siteId'] = $this->getSiteId();
        }

        if (!in_array('additionalDomains', $ignore)) {
            $data['additionalDomains'] = $this->modelArrayToArray(
                $this->getAdditionalDomains()->toArray(),
                ['additionalDomains', 'domainValidator', 'site']
            );
        }

        // @bc support
        if (!in_array('domain', $ignore)) {
            $data['domain'] = $this->getDomainName();
        }

        if (!in_array('isPrimary', $ignore)) {
            $data['isPrimary'] = $this->isPrimary();
        }

        if (!in_array('isPrimaryDomain', $ignore)) {
            $data['isPrimaryDomain'] = $this->isPrimaryDomain();
        }

        return $data;
    }
329203
public function populate($data = array())
    {
        if (isset($data['answer']) && $data['answer'] !== null) {
            $this->answer = $data['answer'];
        }

        if (isset($data['explanation']) && $data['explanation'] !== null) {
            $this->explanation = $data['explanation'];
        }

        if (isset($data['jsonData']) && $data['jsonData'] !== null) {
            $this->jsonData = $data['jsonData'];
        }

        if (isset($data['type']) && $data['type'] !== null) {
            $this->type = $data['type'];
        }

        if (isset($data['position']) && $data['position'] !== null) {
            $this->position = $data['position'];
        }

        if (isset($data['image']) && $data['image'] !== null) {
            $this->image = $data['image'];
        }

        if (isset($data['video']) && $data['video'] !== null) {
            $this->video = $data['video'];
        }

        if (isset($data['points']) && $data['points'] !== null) {
            $this->points = $data['points'];
        }

        if (isset($data['correct']) && $data['correct'] !== null) {
            $this->correct = $data['correct'];
        }
    }
509638
public function populateFromObject(
        ApiPopulatableInterface $object,
        array $ignore = []
    ) {
        if (!$object instanceof Site) {
            return;
        }
        if (!in_array('siteId', $ignore)) {
            $this->setSiteId($object->getSiteId());
        }
        if (is_object($object->getDomain()) && !in_array('domain', $ignore)) {
            $this->setDomain($object->getDomain());
        }
        if (!in_array('theme', $ignore)) {
            $this->setTheme($object->getTheme());
        }
        if (!in_array('siteLayout', $ignore)) {
            $this->setSiteLayout($object->getSiteLayout());
        }
        if (!in_array('siteTitle', $ignore)) {
            $this->setSiteTitle($object->getSiteTitle());
        }
        if (is_object($object->getLanguage()) && !in_array('language', $ignore)) {
            $this->setLanguage($object->getLanguage());
        }
        if (is_object($object->getCountry()) && !in_array('country', $ignore)) {
            $this->setCountry($object->getCountry());
        }
        if (!in_array('status', $ignore)) {
            $this->setStatus($object->getStatus());
        }
        if (!in_array('favIcon', $ignore)) {
            $this->setFavIcon($object->getFavIcon());
        }
        if (!in_array('loginPage', $ignore)) {
            $this->setLoginPage($object->getLoginPage());
        }
        if (!in_array('notAuthorizedPage', $ignore)) {
            $this->setNotAuthorizedPage($object->getNotAuthorizedPage());
        }
        if (!in_array('notFoundPage', $ignore)) {
            $this->setNotFoundPage($object->getNotFoundPage());
        }
        if (!in_array('supportedPageTypes', $ignore)) {
            $this->setSupportedPageTypes($object->getSupportedPageTypes());
        }
    }
646921
public function populate($object, array $data)
    {
        if (!is_object($object)) {
            throw new \InvalidArgumentException('The first param should be a object.');
        }

        if ($object instanceof Array2ObjectInterface) {
            $object->__populate($data);
        } else {
            //this static cache is helpful when populate
            //many objects of the same type in a loop
            static $matcherCache = [];
            static $writerCache = [];

            $objectClass = get_class($object);
            $properties = Utils::getClassProperties($objectClass);
            foreach ($properties as $property) {
                //save in cache if the property is writable
                $writableCacheHash = $objectClass.$property->getName();
                if (!isset($writerCache[$writableCacheHash])) {
                    $writerCache[$writableCacheHash] = $this->context->getWriter()->isWritable($object, $property->getName());
                }
                foreach ($data as $key => $value) {
                    //save in cache if the property name match with key
                    $propHash = $objectClass.$property->getName().$key;
                    if (!isset($matcherCache[$propHash])) {
                        $matcherCache[$propHash] = $this->context->getMatcher()->match($property, $key);
                    }

                    if ($writerCache[$writableCacheHash] && $matcherCache[$propHash]) {
                        $types = Utils::getPropertyTypes($property);
                        $value = $this->parseValue($value, $types, $property, $object);
                        $this->context->getWriter()->setValue($object, $property->getName(), $value);
                    }
                }
            }
        }
    }
926389
public function applyData ( $data = NULL ) {
        if (NULL != $data && is_array( $data )) {
            foreach ($data as $propName => $propValue) {
                $this->assignValue( $propName, $propValue );
            }
        } else {
            $this->buildVars();
        }
    }