Adds or removes a social profile from the collection.

@param array $data
@param Collection $object
@see \Zend\Hydrator\HydratorInterface::hydrate()
@return \Auth\Entity\SocialProfiles\ProfileInterface
491304
public function hydrate(array $data, $object)
    {
        foreach ($data as $name => $value) {
            if (!isset($this->profileClassMap[$name])) {
                continue;
            }
            
            if (empty($value)) {
                // We need to check, if collection has a profile and
                // remove it.
                foreach ($object as $p) {
                    if ($p instanceof $this->profileClassMap[$name]) {
                        $object->removeElement($p);
                        continue 2;
                    }
                }
                // No profile found, so do nothing.
                continue;
            }
            
            if (is_string($value)) {
                $value = \Zend\Json\Json::decode($value, \Zend\Json\Json::TYPE_ARRAY);
            }

            /* If there is already a profile of this type, we do not need to
             * add it, but update the data only.
             */
            foreach ($object as $p) {
                if ($p instanceof $this->profileClassMap[$name]) {
                    // Already a profile in the collection, just update and continue main loop.
                    $p->setData($value);
                    continue 2;
                }
            }
                
            // We need to add a new profile to the collection.
            $class = $this->profileClassMap[$name];
            $profile = new $class();
            $profile->setData($value);
            $object->add($profile);
        }
        return $object;
    }
536213
public function hydrate( array $data, $object )
    {
        if ( isset( $data['properties'] ) &&
             is_array( $data['properties'] ) )
        {
            foreach ( $data['properties'] as $key => $value )
            {
                $newKey = String::decamelize( $key );

                if ( $newKey != $key )
                {
                    $data['properties'][$newKey] = $value;
                    unset( $data['properties'][$key] );
                }
            }
        }

        return $this->getMapper()
                    ->hydrate( $data, $object );
    }
277830
public function createFromData(array $data, array $map = null)
    {
        $object = $this->create();
        $this->hydrator->hydrate($data, $object, $map);
        return $object;
    }
1222373
public function hydrate(array $data, $object)
    {
        if (isset($data['timestamp'])) {
            $object->setCreatedAt(new \DateTime($data['timestamp']));
        }
        if (isset($data['resource-title'])) {
            $object->setTitle($data['resource-title']);
        }
        if (isset($data['resource-type'])) {
            $object->setType($data['resource-type']);
        }
        if (isset($data['message'])) {
            $object->setMessage($data['message']);
        }
        if (isset($data['containing-class'])) {
            $object->setClassName($data['containing-class']);
        }
        if (isset($data['certname'])) {
            $object->setNodeName($data['certname']);
        }
        if (isset($data['status'])) {
            $object->setStatus($data['status']);
        }
        return $object;
    }
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;
    }
1011286
public function hydrate(array $data, $object)
    {
        if (! $object instanceof Entity) {
            return $object;
        }
                
        parent::hydrate($data, $object);
               
        $authEntity = parent::hydrate($data, new \Pacificnm\Auth\Entity\Entity());
        
        $object->setAuthEntity($authEntity);
        
        $aclRoleEntity = parent::hydrate($data, new \Pacificnm\AclRole\Entity\Entity());
        
        $object->getAuthEntity()->setAclRoleEntity($aclRoleEntity);
        
        return $object;
    }
53983
public function hydrate(array $data, $object)
    {
        if (!$object instanceof UserBlock) {
            throw new \Exception('$object must be an instance of UserBlock');
        }

        return parent::hydrate($data, $object);
    }
86345
public function hydrate(array $data, $classNameOrObject)
    {
        $object = $this->buildObject($classNameOrObject);

        return parent::hydrate($data, $object);
    }
398388
public function mutateClass(DataObject $object, $identifier, $data)
    {
        $class = $this->getClass();
        
        if ($object->ClassName != $class) {
            
            // Show Notice Message:
            
            $this->noticeMessage(
                sprintf(
                    'Mutating %s (%s to %s)',
                    $identifier,
                    get_class($object),
                    $class
                )
            );
            
            // Mutate Object:
            
            $object = $object->newClassInstance($class);
            
            // Write Object to Database:
            
            $object->write();
            $object->flushCache();
            
        }
        
        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;
    }
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;
    }
179683
public function hydrate(array $data, $object)
    {
        if (!$object instanceof TicketSubject) {
            throw new \InvalidArgumentException('$object must be an instance of TicketSubject');
        }

        return parent::hydrate($data, $object);
    }
1143408
public function hydrate(ObjectInterface $object, Property $property, GenerationContext $context): ObjectInterface
    {
        $instance = $object->getInstance();
        try {
            $this->propertyAccessor->setValue($instance, $property->getName(), $property->getValue());
        } catch (SymfonyNoSuchPropertyException $exception) {
            throw HydrationExceptionFactory::createForCouldNotHydrateObjectWithProperty($object, $property, 0, $exception);
        } catch (SymfonyAccessException $exception) {
            throw HydrationExceptionFactory::createForInaccessibleProperty($object, $property, 0, $exception);
        } catch (SymfonyInvalidArgumentException $exception) {
            throw HydrationExceptionFactory::createForInvalidProperty($object, $property, 0, $exception);
        } catch (SymfonyPropertyAccessException $exception) {
            throw HydrationExceptionFactory::create($object, $property, 0, $exception);
        } catch (TypeError $error) {
            throw HydrationExceptionFactory::createForInvalidProperty($object, $property, 0, $error);
        }

        return new SimpleObject($object->getId(), $instance);
    }
1195533
public function hydrate(array $data, $object)
    {
        $array = [];
        $hydrator = new AnnotationHydrator();

        foreach ($data as $value) {
            $clonedObject = clone $object;
            $array[] = $hydrator->hydrate($value, $clonedObject);
        }

        return $array;
    }
661886
public function removeObject(DataObject $object)
    {
        $item = ChangeSetItem::get()->filter([
            'ObjectID' => $object->ID,
            'ObjectClass' => $object->baseClass(),
            'ChangeSetID' => $this->ID
        ])->first();

        if ($item) {
            // TODO: Handle case of implicit added item being removed.

            $item->delete();
        }

        $this->sync();
    }
804263
public function hydrate(array $data, $object)
    {
        if (!$object instanceof PageInfo) {
            throw new \Exception('$object must be an instance of PageInfo');
        }

        return parent::hydrate($data, $object);
    }
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;
    }