當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Hydrator\ClassMethods類代碼示例

本文整理匯總了PHP中Zend\Stdlib\Hydrator\ClassMethods的典型用法代碼示例。如果您正苦於以下問題:PHP ClassMethods類的具體用法?PHP ClassMethods怎麽用?PHP ClassMethods使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ClassMethods類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setComments

 public function setComments($comments)
 {
     $hydrator = new ClassMethods();
     foreach ($comments as $c) {
         $this->comments[] = $hydrator->hydrate($c, new Comment());
     }
 }
開發者ID:navidnahidi,項目名稱:zf2_client,代碼行數:7,代碼來源:Status.php

示例2: 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;
 }
開發者ID:jhonmike,項目名稱:zf-user,代碼行數:32,代碼來源:User.php

示例3: execute

 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));
 }
開發者ID:gravitymedia,項目名稱:metadata,代碼行數:32,代碼來源:ExportId3v1Command.php

示例4: extract

 public function extract($object)
 {
     $classMethods = new ClassMethods();
     $properties = $classMethods->extract($object);
     unset($properties['alternative']);
     return $properties;
 }
開發者ID:danielventura90,項目名稱:calz,代碼行數:7,代碼來源:MyHydrator.php

示例5: init

 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')));
 }
開發者ID:shinesoftware-zf-modules,項目名稱:Customer,代碼行數:33,代碼來源:CustomerForm.php

示例6: __invoke

 public function __invoke($services)
 {
     $hydrator = new ClassMethods();
     $hydrator->addStrategy('createdDatetime', new DatetimeStrategy());
     $hydrator->addStrategy('lastModified', new DatetimeStrategy());
     return $hydrator;
 }
開發者ID:nobesnickr,項目名稱:ApiTimesheets,代碼行數:7,代碼來源:EntityHydratorFactory.php

示例7: buildHydrator

 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;
 }
開發者ID:pay4later,項目名稱:php-task,代碼行數:35,代碼來源:AbstractClassAdapter.php

示例8: __construct

 public function __construct($data = null)
 {
     if (null !== $data) {
         $hydrator = new \Zend\Stdlib\Hydrator\ClassMethods();
         $hydrator->hydrate($data, $this);
     }
 }
開發者ID:KGalley,項目名稱:whathood,代碼行數:7,代碼來源:HeatMap.php

示例9: setArticles

 public function setArticles($articles)
 {
     $hydrator = new ClassMethods();
     foreach ($articles as $a) {
         $this->articles[] = $hydrator->hydrate($a, new Article());
     }
 }
開發者ID:navidnahidi,項目名稱:zf2_client,代碼行數:7,代碼來源:Feed.php

示例10: 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;
 }
開發者ID:nobesnickr,項目名稱:ApiTimesheets,代碼行數:27,代碼來源:ClientRateLimitConfigService.php

示例11: createService

 /**
  * 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);
 }
開發者ID:summerandelf,項目名稱:CotestWeb_,代碼行數:13,代碼來源:UserServiceFactory.php

示例12: saveVideo

 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;
 }
開發者ID:nowarena,項目名稱:zf2NowArena,代碼行數:25,代碼來源:VideosMapper.php

示例13: fromArray

 public function fromArray($values)
 {
     $hydrator = new Hydrator\ClassMethods();
     $hydrator->setUnderscoreSeparatedKeys(false);
     $res = $hydrator->hydrate($values, $this);
     return $res;
 }
開發者ID:fuca,項目名稱:sportsclub,代碼行數:7,代碼來源:EntityMapperTrait.php

示例14: toArray

 public function toArray()
 {
     $hydrator = new ClassMethods();
     $data = $hydrator->extract($this);
     $data['perfil'] = $data['usuario']->getGrupo()->getId();
     $data['login'] = $data['usuario']->getLogin();
     return $data;
 }
開發者ID:ericoautocad,項目名稱:module-security-zf2,代碼行數:8,代碼來源:Funcionario.php

示例15: createService

 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);
 }
開發者ID:FiftyNine,項目名稱:ScpperDB,代碼行數:8,代碼來源:VoteDbSqlMapperFactory.php


注:本文中的Zend\Stdlib\Hydrator\ClassMethods類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。