本文整理汇总了PHP中Zend\Stdlib\Hydrator\ClassMethods::hydrate方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMethods::hydrate方法的具体用法?PHP ClassMethods::hydrate怎么用?PHP ClassMethods::hydrate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Stdlib\Hydrator\ClassMethods
的用法示例。
在下文中一共展示了ClassMethods::hydrate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: persist
public function persist(array $data, $id = null)
{
if (empty($data['password'])) {
unset($data['password']);
}
$data['role'] = $this->em->getReference("Zf2Acl\\Entity\\Role", $data['role']);
if ($id) {
$entity = $this->em->getReference($this->entity, $id);
$entity_perfil = $this->em->getReference("Zf2User\\Entity\\Perfil", $data['perfil']['id']);
$hydrator = new Hydrator\ClassMethods();
$hydrator->hydrate($data, $entity);
$data['perfil']['user'] = $entity;
$hydrator->hydrate($data['perfil'], $entity_perfil);
} else {
$entity = new $this->entity($data);
$data['perfil']['user'] = $entity;
$entity_perfil = new \Zf2User\Entity\Perfil($data['perfil']);
}
$this->em->persist($entity);
$this->em->persist($entity_perfil);
$this->em->flush();
if ($entity->getStatus() == 0) {
// $dataEmail = array('email' => $entity->getEmail(), 'activationKey' => $entity->getActivationKey());
// $mail = new Mail($this->transport, $this->view, 'add-user');
// $mail->setSubject('Confirmação de cadastro')
// ->setTo($entity->getEmail())
// ->setData($dataEmail)
// ->prepare()
// ->send();
}
return $entity;
}
示例2: setFeed
public function setFeed($feed)
{
$hydrator = new ClassMethods();
foreach ($feed as $entry) {
if (array_key_exists('status', $entry)) {
$this->feed[] = $hydrator->hydrate($entry, new Status());
} else {
if (array_key_exists('filename', $entry)) {
$this->feed[] = $hydrator->hydrate($entry, new Image());
}
}
}
}
示例3: hydrate
public function hydrate(array $data, $object)
{
if (!$object instanceof ActivityInterface) {
throw new Exception\InvalidArgumentException('$object must be an instance of Cobalt\\Model\\Activity\\ActivityInterface');
}
return parent::hydrate($data, $object);
}
示例4: hydrate
public function hydrate(array $data, $object)
{
if (!$object instanceof ProjectInterface) {
throw new \InvalidArgumentException('$object must be an instance of Application\\Model\\Project\\ProjectInterface');
}
return parent::hydrate($data, $object);
}
示例5: hydrate
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param object $object
* @return object
* @throws \Exception
*/
public function hydrate(array $data, $object)
{
if (!in_array('ShoppingCart\\Entity\\ShoppingCartEntityInterface', class_implements($object))) {
throw new \Exception('$object must implement ShoppingCart\\Entity\\ShoppingCartEntityInterface');
}
return parent::hydrate($data, $object);
}
示例6: hydrate
public function hydrate(array $data, $object)
{
if (!$object instanceof SubstanceInterface) {
throw new \InvalidArgumentException('$object must be an instance of ' . __NAMESPACE__ . '\\SubstanceInterface');
}
return parent::hydrate($data, $object);
}
示例7: __construct
public function __construct($data = null)
{
if (null !== $data) {
$hydrator = new \Zend\Stdlib\Hydrator\ClassMethods();
$hydrator->hydrate($data, $this);
}
}
示例8: __construct
/**
* Constructor
*/
public function __construct($options = array())
{
$hydrator = new Hydrator\ClassMethods();
$hydrator->hydrate($options, $this);
$this->created = new \DateTime("now");
$this->updated = new \DateTime("now");
}
示例9: fetch
public function fetch()
{
$authenticatedIdentity = $this->getApiIdentity();
if ($authenticatedIdentity instanceof GuestIdentity) {
$identity = $_SERVER['REMOTE_ADDR'];
} elseif ($authenticatedIdentity instanceof AuthenticatedIdentity) {
$identityDetails = $authenticatedIdentity->getAuthenticationIdentity();
if (array_key_exists('client_id', $identityDetails)) {
$identity = $identityDetails['client_id'];
} else {
$identity = $_SERVER['REMOTE_ADDR'];
}
} else {
throw new \InvalidArgumentException('Invalid Identity Type Provided');
}
if (array_key_exists($identity, $this->getConfig())) {
$clientConfigArray = $this->getConfig()[$identity];
}
if (empty($clientConfigArray)) {
$clientConfigArray = $this->getConfig()['default'];
}
$clientRateLimitConfig = new ClientRateLimitConfig();
$hydrator = new ClassMethods();
$hydrator->hydrate($clientConfigArray, $clientRateLimitConfig);
$clientRateLimitConfig->setIdentity($identity);
return $clientRateLimitConfig;
}
示例10: setComments
public function setComments($comments)
{
$hydrator = new ClassMethods();
foreach ($comments as $c) {
$this->comments[] = $hydrator->hydrate($c, new Comment());
}
}
示例11: hydrate
/**
* hydrate
*
* @param unknown_type $object
* @throws Exception\InvalidArgumentException
*/
public function hydrate(array $data, $object)
{
if (!$object instanceof VisitInterface) {
throw new Exception\InvalidArgumentException('$object must be an instance of Zf2Forum\\Model\\Visit\\VisitInterface');
}
return parent::hydrate($data, $object);
}
示例12: hydrate
/**
* @param array $data
* @param object $object
* @return Error
*/
public function hydrate(array $data, $object)
{
if (!isset($data['error'])) {
return $object;
}
return parent::hydrate($data['error'], new Error());
}
示例13: hydrate
/**
* Hydrate $object with the provided $data.
*
* @param array $data
* @param object $object
* @return CountryInterface
* @throws Exception\InvalidArgumentException
*/
public function hydrate(array $data, $object)
{
if (!$object instanceof CountryEntityInterface) {
throw new Exception\InvalidArgumentException('$object must be an instance of DelCountriesFlags\\Entity\\CountryInterface');
}
return parent::hydrate($data, $object);
}
示例14: fromArray
public function fromArray($values)
{
$hydrator = new Hydrator\ClassMethods();
$hydrator->setUnderscoreSeparatedKeys(false);
$res = $hydrator->hydrate($values, $this);
return $res;
}
示例15: __construct
/**
* Constructor
*/
public function __construct(array $data)
{
$this->caracteristicaPerfil = new \Doctrine\Common\Collections\ArrayCollection();
$this->produto = new \Doctrine\Common\Collections\ArrayCollection();
$hydrator = new ClassMethods();
$hydrator->hydrate($data, $this);
}