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; }
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()); } } } }
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); }
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); }
/** * 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); }
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); }
public function __construct($data = null) { if (null !== $data) { $hydrator = new \Zend\Stdlib\Hydrator\ClassMethods(); $hydrator->hydrate($data, $this); } }
/** * Constructor */ public function __construct($options = array()) { $hydrator = new Hydrator\ClassMethods(); $hydrator->hydrate($options, $this); $this->created = new \DateTime("now"); $this->updated = new \DateTime("now"); }
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; }
public function setComments($comments) { $hydrator = new ClassMethods(); foreach ($comments as $c) { $this->comments[] = $hydrator->hydrate($c, new Comment()); } }
/** * 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); }
/** * @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()); }
/** * 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); }
public function fromArray($values) { $hydrator = new Hydrator\ClassMethods(); $hydrator->setUnderscoreSeparatedKeys(false); $res = $hydrator->hydrate($values, $this); return $res; }
/** * 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); }
public function hydrate(array $data, $model) { $model = parent::hydrate($data, $model); $model->setRequired((bool) $model->getRequired()); $model->setBuilder((bool) $model->getBuilder()); return $model; }
public function hydrate(array $data, $object) { if (!$object instanceof StaffInterface) { throw new Exception\InvalidArgumentException('$object must be an instance of Nickel\\Model\\Staff\\StaffInterface'); } return parent::hydrate($data, $object); }
/** * Hydrate $object with the provided $data. * * @param array $data * @param object $object * @return UserInterface * @throws Exception\InvalidArgumentException */ public function hydrate(array $data, $object) { if (!$object instanceof LoggerEntity) { throw new Exception\InvalidArgumentException('$object must be an instance of Logger\\Entity\\Logger'); } return parent::hydrate($data, $object); }
public function setArticles($articles) { $hydrator = new ClassMethods(); foreach ($articles as $a) { $this->articles[] = $hydrator->hydrate($a, new Article()); } }
public function __construct($array = null) { if ($array !== null) { $hydrator = new ClassMethodHydrator(); $hydrator->hydrate($array, $this); } }
/** * Converts the given value so that it can be hydrated by the hydrator. * * @param mixed $value The original value. * @return mixed Returns the value that should be hydrated. */ public function hydrate($value) { if (!is_array($value)) { return $value; } $hydrator = new ClassMethods(true); return $hydrator->hydrate($value, new CardEntity()); }
/** * @param User $user */ public function update(User $user) { $mapper = $this->getUserMapper(); $mapper->update($user); $fresh = $mapper->get($user->getId()); $hydrator = new ClassMethods(); $hydrator->hydrate($hydrator->extract($fresh), $user); }
/** * Constructor */ public function __construct(array $data) { $this->pedidoItem = new \Doctrine\Common\Collections\ArrayCollection(); $this->produtoAtributo = new \Doctrine\Common\Collections\ArrayCollection(); $this->produto = new \Doctrine\Common\Collections\ArrayCollection(); $hydrator = new ClassMethods(); $hydrator->hydrate($data, $this); }
public function hydrate(array $data, $object) { $this->validateEntity($object, __METHOD__); if (!$data['request_time'] instanceof \DateTime) { $data['request_time'] = new \DateTime($data['request_time']); } return parent::hydrate($data, $object); }
/** * Hydrate $object with the provided $data. * * @param array $data * @param object $object * @return UserInterface * @throws Exception\InvalidArgumentException */ public function hydrate(array $data, $object) { if (!$object instanceof ModuleEntityInterface) { throw new Exception\InvalidArgumentException('$object must be an instance of Application\\Entity\\ModuleEntityInterface'); } $data = $this->mapField('module_id', 'id', $data); return parent::hydrate($data, $object); }
/** * Hydrate $object with the provided $data. * * @param array $data * @param object $object * @return UserInterface * @throws Exception\InvalidArgumentException */ public function hydrate(array $data, $object) { if (!$object instanceof UserEntityInterface) { throw new Exception\InvalidArgumentException('$object must be an instance of ZfcUser\\Entity\\UserInterface'); } $data = $this->mapField('user_id', 'id', $data); return parent::hydrate($data, $object); }
public function getArraySession(WcUser $user) { $arraySession = ['id' => $user->getId(), 'firstname' => $user->getFirstname(), 'lastname' => $user->getLastname(), 'email' => $user->getEmail(), 'level' => $user->getLevel(), 'status' => $user->getStatus(), 'owner' => ['id' => $user->getOwner()->getId(), 'firstname' => $user->getOwner()->getFirstname(), 'lastname' => $user->getOwner()->getLastname(), 'email' => $user->getOwner()->getEmail()], 'language' => ['id' => $user->getLanguage()->getId(), 'name' => $user->getLanguage()->getName(), 'flag' => $user->getLanguage()->getFlag(), 'abbreviation' => $user->getLanguage()->getAbbreviation()], 'created_at' => $user->getCreatedAt()->format('Y-m-d H:i:s'), 'updated_at' => $user->getUpdatedAt()->format('Y-m-d H:i:s'), 'user_created' => ['id' => $user->getUserCreated() ? $user->getUserCreated()->getId() : '', 'firstname' => $user->getUserCreated() ? $user->getUserCreated()->getFirstname() : '', 'lastname' => $user->getUserCreated() ? $user->getUserCreated()->getLastname() : '', 'email' => $user->getUserCreated() ? $user->getUserCreated()->getEmail() : ''], 'user_updated' => ['id' => $user->getUserUpdated() ? $user->getUserUpdated()->getId() : '', 'firstname' => $user->getUserUpdated() ? $user->getUserUpdated()->getFirstname() : '', 'lastname' => $user->getUserUpdated() ? $user->getUserUpdated()->getLastname() : '', 'email' => $user->getUserUpdated() ? $user->getUserUpdated()->getEmail() : '']]; $object = new ClassMethods(); /** @var \Auth\Service\AuthUserEntity $authUserEntity */ $authUserEntity = new AuthUserEntity(); $object->hydrate($arraySession, $authUserEntity); return $authUserEntity; }
/** * Hydrate $object with the provided $data. * * @param array $data * @param object $object * @return UserInterface * @throws Exception\InvalidArgumentException */ public function hydrate(array $data, $object) { if (!$object instanceof BreakerEntityInterface) { //throw new Exception\InvalidArgumentException('$object must be an instance of Acl\Entity\UserInterface'); throw new RuntimeException('$object must be an instance of Project\\Entity\\ProjectInterface'); } // $data = $this->mapField('user_id', 'id', $data); return parent::hydrate($data, $object); }
public function editarDadosPessoais($data, $idUsuario) { $dadosPessoais = $this->getEm('Admin\\Entity\\DadosPessoais')->findOneByUsuario($idUsuario); $hydrator = new ClassMethods(); $hydrator->hydrate($data, $dadosPessoais); $this->getEm()->persist($dadosPessoais); $this->getEm()->flush(); return $dadosPessoais; }
/** * Hydrate $object with the provided $data. * * @param array $data * @param object $object * @return MessageInterface * @throws Exception\InvalidArgumentException */ public function hydrate(array $data, $object) { if (!$object instanceof MessageEntityInterface) { throw new Exception\InvalidArgumentException('$object must be an instance of EdpDiscuss\\Model\\Message\\MessageInterface'); } // example of mapping a field $data = $this->mapField('user_id', 'id', $data); return parent::hydrate($data, $object); }