作者:navidnahid
项目:zf2_clien
public function setComments($comments)
{
$hydrator = new ClassMethods();
foreach ($comments as $c) {
$this->comments[] = $hydrator->hydrate($c, new Comment());
}
}
作者:jhonmik
项目:zf-use
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;
}
作者:gravitymedi
项目:metadat
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));
}
作者:danielventura9
项目:cal
public function extract($object)
{
$classMethods = new ClassMethods();
$properties = $classMethods->extract($object);
unset($properties['alternative']);
return $properties;
}
作者:shinesoftware-zf-module
项目:Custome
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')));
}
作者:nobesnick
项目:ApiTimesheet
public function __invoke($services)
{
$hydrator = new ClassMethods();
$hydrator->addStrategy('createdDatetime', new DatetimeStrategy());
$hydrator->addStrategy('lastModified', new DatetimeStrategy());
return $hydrator;
}
作者:pay4late
项目:php-tas
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;
}
作者:KGalle
项目:whathoo
public function __construct($data = null)
{
if (null !== $data) {
$hydrator = new \Zend\Stdlib\Hydrator\ClassMethods();
$hydrator->hydrate($data, $this);
}
}
作者:navidnahid
项目:zf2_clien
public function setArticles($articles)
{
$hydrator = new ClassMethods();
foreach ($articles as $a) {
$this->articles[] = $hydrator->hydrate($a, new Article());
}
}
作者:nobesnick
项目:ApiTimesheet
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;
}
作者:summerandel
项目:CotestWeb
/**
* 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);
}
作者:nowaren
项目:zf2NowAren
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;
}
作者:fuc
项目:sportsclu
public function fromArray($values)
{
$hydrator = new Hydrator\ClassMethods();
$hydrator->setUnderscoreSeparatedKeys(false);
$res = $hydrator->hydrate($values, $this);
return $res;
}
作者:ericoautoca
项目:module-security-zf
public function toArray()
{
$hydrator = new ClassMethods();
$data = $hydrator->extract($this);
$data['perfil'] = $data['usuario']->getGrupo()->getId();
$data['login'] = $data['usuario']->getLogin();
return $data;
}
作者:FiftyNin
项目:ScpperD
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);
}
作者:sydnerdrag
项目:sample-servic
/**
* @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);
}
作者:continuousph
项目:zoho-subscription
/**
* 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());
}
作者:RodrigoAngeloValentin
项目:curso-zf
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;
}
作者:FiftyNin
项目:ScpperD
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, '');
}
作者:phpr
项目:zf-chart
/**
* {@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;
}