public function setComments($comments) { $hydrator = new ClassMethods(); foreach ($comments as $c) { $this->comments[] = $hydrator->hydrate($c, new Comment()); } }
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; }
protected function execute(InputInterface $input, OutputInterface $output) { $inputFile = new SplFileInfo($input->getArgument('input')); $tag = $inputFile->getMetadata()->getId3v1Tag(); $hydrator = new ClassMethods(); $data = $hydrator->extract($tag); $data['audio_properties'] = $hydrator->extract($data['audio_properties']); foreach (array_keys($data) as $name) { if (null === $data[$name]) { unset($data[$name]); } } $format = $input->getOption('format'); if (!in_array($format, array(self::FORMAT_YAML))) { $format = self::FORMAT_YAML; } switch ($format) { case self::FORMAT_YAML: $data = Yaml::dump($data); break; } $outputFilename = $input->getArgument('output'); if (null === $outputFilename) { $output->writeln('<info>' . $data . '</info>'); return; } if (file_put_contents($outputFilename, $data)) { $output->writeln(sprintf('<info>Metadata file \'%s\' successfully exported.</info>', $outputFilename)); return; } $output->writeln(sprintf('<error>Unable to write metadata file \'%s\'.</error>', $outputFilename)); }
public function extract($object) { $classMethods = new ClassMethods(); $properties = $classMethods->extract($object); unset($properties['alternative']); return $properties; }
public function init() { $hydrator = new ClassMethods(); $hydrator->addStrategy('birthdate', new DateTimeStrategy()); $this->setAttribute('method', 'post'); $this->setHydrator($hydrator)->setObject(new \Customer\Entity\Customer()); $this->add(array('name' => 'company', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Company')))); $this->add(array('name' => 'firstname', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('First name')))); $this->add(array('name' => 'lastname', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Last name')))); $this->add(array('name' => 'note', 'attributes' => array('type' => 'textarea', 'class' => 'wysiwyg'), 'options' => array('label' => _('Private Notes')))); $this->add(array('name' => 'birthdate', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth date')))); $this->add(array('name' => 'birthplace', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth place')))); $this->add(array('name' => 'birthdistrict', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth district')))); $this->add(array('name' => 'birthcountry', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth country')))); $this->add(array('name' => 'birthnationality', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Birth nationality')))); $this->add(array('name' => 'taxpayernumber', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Tax payer number')))); $this->add(array('name' => 'vat', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('VAT')))); $this->add(array('type' => 'Customer\\Form\\Element\\CustomerGroup', 'name' => 'group_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Customer Group')))); $this->add(array('type' => 'Base\\Form\\Element\\Languages', 'name' => 'language_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Language')))); $this->add(array('type' => 'Customer\\Form\\Element\\Legalform', 'name' => 'legalform_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Legal form')))); $this->add(array('type' => 'Customer\\Form\\Element\\Companytype', 'name' => 'type_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Company Type')))); $this->add(array('type' => 'Customer\\Form\\Element\\Status', 'name' => 'status_id', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Status'), 'section' => 'customers'))); $this->add(array('type' => 'Zend\\Form\\Element\\File', 'name' => 'file', 'attributes' => array('class' => ''), 'options' => array('label' => _('Upload Document')), 'filters' => array(array('required' => false)))); $this->add(array('name' => 'contact', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Contact')))); $this->add(array('type' => 'Customer\\Form\\Element\\ContactType', 'name' => 'contacttype', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Contact Type')))); $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'gender', 'attributes' => array('class' => 'form-control'), 'options' => array('label' => _('Gender'), 'value_options' => array('M' => _('Male'), 'F' => _('Female'))))); // This is a fieldset $this->add(array('name' => 'address', 'type' => '\\Customer\\Form\\Fieldset\\AddressFieldset', 'object' => '\\Customer\\Entity\\Address', 'options' => array('use_as_base_fieldset' => false))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'class' => 'btn btn-success', 'value' => _('Save')))); $this->add(array('name' => 'user_id', 'attributes' => array('type' => 'hidden'))); $this->add(array('name' => 'uid', 'attributes' => array('type' => 'hidden'))); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); }
public function __invoke($services) { $hydrator = new ClassMethods(); $hydrator->addStrategy('createdDatetime', new DatetimeStrategy()); $hydrator->addStrategy('lastModified', new DatetimeStrategy()); return $hydrator; }
protected function buildHydrator($product, $direction) { $this->assertOptionsValid(); $config = $this->options->getConfig(); $class = $this->options->getClass(); $hydrator = new ClassMethods(); if (!isset($config[$this->options->getClass()][$product])) { return $hydrator; } $tmp = new Config(array()); if (isset($config[$class]['*'])) { $tmp = new Config($config[$class]['*']); } if (isset($config[$class][$product])) { $productConfig = new Config($config[$class][$product]); $tmp = $productConfig->merge($tmp); } $config = $tmp['shared']; if (isset($tmp[$direction])) { $config->merge($tmp[$direction]); } $config = $config->toArray(); if (!empty($config['map'])) { $hydrator->setNamingStrategy(new ArrayMapNamingStrategy($config['map'])); } if (!empty($config['strategy'])) { foreach ($config['strategy'] as $name => $strategyCallback) { $hydrator->addStrategy($name, $strategyCallback()); } } if (!empty($config['options'])) { $this->options->setFromArray($config['options']); } return $hydrator; }
public function __construct($array = null) { if ($array !== null) { $hydrator = new ClassMethodHydrator(); $hydrator->hydrate($array, $this); } }
public function __construct($data = null) { if (null !== $data) { $hydrator = new \Zend\Stdlib\Hydrator\ClassMethods(); $hydrator->hydrate($data, $this); } }
public function setArticles($articles) { $hydrator = new ClassMethods(); foreach ($articles as $a) { $this->articles[] = $hydrator->hydrate($a, new Article()); } }
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; }
/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { $classmethod = new ClassMethods(false); $classmethod->addFilter("arraycoppy", new MethodMatchFilter("getArrayCopy"), FilterComposite::CONDITION_AND); $classmethod->addFilter("inputFilter", new MethodMatchFilter("getInputFilter"), FilterComposite::CONDITION_AND); return new UserService($serviceLocator->get('Zend\\Db\\Adapter\\Adapter'), $classmethod); }
public function saveVideo(VideosEntity $ent) { $hydrator = new ClassMethods(); $data = $hydrator->extract($ent); $select = $this->sql->select(); $whereArr = array('video_id' => $ent->getVideoId()); $select->where($whereArr); $statement = $this->sql->prepareStatementForSqlObject($select); $results = $statement->execute(); $result = false; if ($results->count() == 0) { // insert action $action = $this->sql->insert(); $action->values($data); $statement = $this->sql->prepareStatementForSqlObject($action); $result = $statement->execute(); } elseif (false && $results->count() > 0) { // update action $action = $this->sql->update(); unset($data['id']); $action->set($data); $action->where(array('video_id' => $ent->getVideoId())); } return $result; }
public function fromArray($values) { $hydrator = new Hydrator\ClassMethods(); $hydrator->setUnderscoreSeparatedKeys(false); $res = $hydrator->hydrate($values, $this); return $res; }
public function toArray() { $hydrator = new ClassMethods(); $data = $hydrator->extract($this); $data['perfil'] = $data['usuario']->getGrupo()->getId(); $data['login'] = $data['usuario']->getLogin(); return $data; }
public function createService(ServiceLocatorInterface $serviceLocator) { $dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter'); $hydrator = new ClassMethods(); $hydrator->addStrategy(DbViewVotes::DATETIME, new DateTimeFormatterStrategy('Y-m-d H:i:s')); $prototype = $serviceLocator->get('VotePrototype'); return new VoteDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewVotes::TABLE, DbViewVotes::__ID); }
/** * @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); }
/** * 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()); }
public function extract($items) { $data = []; foreach ($items as $item) { $data[] = $this->hydrator->extract($item); } return $data; }
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; }
public function createService(ServiceLocatorInterface $serviceLocator) { $dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter'); $hydrator = new ClassMethods(); $names = new \Zend\Stdlib\Hydrator\NamingStrategy\MapNamingStrategy(array(DbViewAuthors::ROLEID => 'role')); $hydrator->setNamingStrategy($names); $prototype = $serviceLocator->get('AuthorshipPrototype'); return new AuthorshipDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewAuthors::TABLE, ''); }
/** * {@inheritdoc} */ public function jsonSerialize() { $hydrator = new ClassMethods(false); $data = $hydrator->extract($this); foreach ($data['datasets'] as $key => $value) { $data['datasets'][$key] = $value->jsonSerialize(); } return $data; }
public function setFeed($feed) { $hydrator = new ClassMethods(); foreach ($feed as $entry) { if (array_key_exists('status', $entry)) { $this->feed[] = $hydrator->hydrate($entry, new Status()); } } }
public function __construct() { $hydrator = new ClassMethods(); $hydrator->setUnderscoreSeparatedKeys(false); foreach (array('getHydrator') as $method) { $hydrator->addFilter($method, new Filter\MethodMatchFilter($method), Filter\FilterComposite::CONDITION_AND); } $this->setHydrator($hydrator); }
public function createService(ServiceLocatorInterface $serviceLocator) { $classmethod = new ClassMethods(false); $classmethod->addFilter("arraycoppy", new MethodMatchFilter("getArrayCopy"), FilterComposite::CONDITION_AND); $classmethod->addFilter("user", new MethodMatchFilter("getUser"), FilterComposite::CONDITION_AND); $prototypeArr = new \ArrayObject(); $prototypeArr->append(new User()); return new ZendDbSqlMapper($serviceLocator->get('Zend\\Db\\Adapter\\Adapter'), $classmethod, new Page(), $prototypeArr); }
public function createService(ServiceLocatorInterface $serviceLocator) { $dbAdapter = $serviceLocator->get('Zend\\Db\\Adapter\\Adapter'); $hydrator = new ClassMethods(); $names = array(DbViewSites::SITEID => 'id'); $hydrator->setNamingStrategy(new MapNamingStrategy($names)); $prototype = $serviceLocator->get('SitePrototype'); return new SiteDbSqlMapper($dbAdapter, $hydrator, $prototype, DbViewSites::TABLE, DbViewSites::SITEID); }
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; }
/** * Get the feed list and the posts of the feed we are looking at now * * @return void */ public function indexAction() { $viewData = array(); $flashMessenger = $this->flashMessenger(); $username = $this->params()->fromRoute('username'); $currentFeedId = $this->params()->fromRoute('feed_id'); $userData = ApiClient::getUser($username); if ($userData !== FALSE) { $hydrator = new ClassMethods(); $user = $hydrator->hydrate($userData, new User()); } else { $this->getResponse()->setStatusCode(404); return; } $subscribeForm = new SubscribeForm(); $unsubscribeForm = new UnsubscribeForm(); $subscribeForm->setAttribute('action', $this->url()->fromRoute('feeds-subscribe', array('username' => $username))); $unsubscribeForm->setAttribute('action', $this->url()->fromRoute('feeds-unsubscribe', array('username' => $username))); $hydrator = new ClassMethods(); $response = ApiClient::getFeeds($username); $feeds = array(); foreach ($response as $r) { $feeds[$r['id']] = $hydrator->hydrate($r, new Feed()); } if ($currentFeedId === null && !empty($feeds)) { $currentFeedId = reset($feeds)->getId(); } $feedsMenu = new Navigation(); $router = $this->getEvent()->getRouter(); $routeMatch = $this->getEvent()->getRouteMatch()->setParam('feed_id', $currentFeedId); foreach ($feeds as $f) { $feedsMenu->addPage(AbstractPage::factory(array('title' => $f->getTitle(), 'icon' => $f->getIcon(), 'route' => 'feeds', 'routeMatch' => $routeMatch, 'router' => $router, 'params' => array('username' => $username, 'feed_id' => $f->getId())))); } $currentFeed = $currentFeedId != null ? $feeds[$currentFeedId] : null; if ($currentFeed != null) { $paginator = new Paginator(new ArrayAdapter($currentFeed->getArticles())); $paginator->setItemCountPerPage(5); $paginator->setCurrentPageNumber($this->params()->fromRoute('page')); $viewData['paginator'] = $paginator; $viewData['feedId'] = $currentFeedId; } $unsubscribeForm->get('feed_id')->setValue($currentFeedId); $viewData['subscribeForm'] = $subscribeForm; $viewData['unsubscribeForm'] = $unsubscribeForm; $viewData['username'] = $username; $viewData['feedsMenu'] = $feedsMenu; $viewData['user'] = $user; $viewData['paginator'] = $paginator; $viewData['feedId'] = $currentFeedId; $viewData['feed'] = $currentFeed; $this->layout()->username = $username; if ($flashMessenger->hasMessages()) { $viewData['flashMessages'] = $flashMessenger->getMessages(); } return $viewData; }
public function getHydrator() { if (!$this->hydrator) { $hydrator = new ClassMethods(); $hydrator->setUnderscoreSeparatedKeys(false); $hydrator->addFilter('getHydrator', new Filter\MethodMatchFilter('getHydrator'), Filter\FilterComposite::CONDITION_AND); $this->hydrator = $hydrator; } return $this->hydrator; }
public function init() { $hydrator = new ClassMethods(); $hydrator->addStrategy('birthdate', new DateTimeStrategy()); $this->setAttribute('method', 'post'); $this->setHydrator($hydrator)->setObject(new \Dummy\Entity\Dummy()); $this->add(array('name' => 'name', 'attributes' => array('type' => 'text', 'class' => 'form-control'), 'options' => array('label' => _('Company')))); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'class' => 'btn btn-success', 'value' => _('Save')))); $this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden'))); }