当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMethods::extract方法代码示例

本文整理汇总了PHP中Zend\Stdlib\Hydrator\ClassMethods::extract方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMethods::extract方法的具体用法?PHP ClassMethods::extract怎么用?PHP ClassMethods::extract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Stdlib\Hydrator\ClassMethods的用法示例。


在下文中一共展示了ClassMethods::extract方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: find

 public function find($id)
 {
     $order = $this->ordersRepository->find($id);
     $client = $this->clientsRepository->findBy(['id' => $order->getClientId()])->current();
     $ptype = $this->ptypesRepository->findBy(['id' => $order->getPtypeId()])->current();
     $user = $this->usersRepository->findBy(['id' => $order->getUserId()])->current();
     $sql = $this->ordersRepository->getItemTable()->getSql();
     $select = $sql->select();
     $select->join('products', 'order_items.product_id = products.id', ['product_name' => 'name'])->where(['order_id' => $order->getId()]);
     $items = $this->ordersRepository->getItemTable()->selectWith($select);
     foreach ($items as $item) {
         $order->addItem($item);
     }
     $hydrator = new ClassMethods();
     $hydrator->addStrategy('items', new OrdersItemsHydratorStrategy(new ClassMethods()));
     $order->setClient($hydrator->extract($client));
     $order->setPtype($hydrator->extract($ptype));
     $order->setUser($hydrator->extract($user));
     $result = $hydrator->extract($order);
     unset($result['client_id']);
     unset($result['ptype_id']);
     unset($result['user_id']);
     unset($result['user']['username']);
     unset($result['user']['password']);
     return $result;
 }
开发者ID:netoudi,项目名称:apigility,代码行数:26,代码来源:OrdersService.php

示例2: 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

示例3: extract

 public function extract($items)
 {
     $data = [];
     foreach ($items as $item) {
         $data[] = $this->hydrator->extract($item);
     }
     return $data;
 }
开发者ID:pedrohglobo,项目名称:apicodeedu,代码行数:8,代码来源:OrderItemHydratorStrategy.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: extract

 public function extract($object)
 {
     $values = parent::extract($object);
     unset($values['arrayCopy']);
     // remove if null
     return array_filter($values);
 }
开发者ID:arstropica,项目名称:zf-tenstreet,代码行数:7,代码来源:TenStreetHydrator.php

示例6: 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

示例7: toArray

 public function toArray()
 {
     $hydrator = new Hydrator\ClassMethods();
     $hydrator->setUnderscoreSeparatedKeys(false);
     $res = $hydrator->extract($this);
     return $res;
 }
开发者ID:fuca,项目名称:sportsclub,代码行数:7,代码来源:EntityMapperTrait.php

示例8: extract

 /**
  * Extract values from an object
  *
  * @param object $object 
  * @return array
  * @throws \Exception
  */
 public function extract($object)
 {
     if (!in_array('ShoppingCart\\Entity\\ShoppingCartEntityInterface', class_implements($object))) {
         throw new \Exception('$object must implement ShoppingCart\\Entity\\ShoppingCartEntityInterface');
     }
     $data = parent::extract($object);
     return $data;
 }
开发者ID:shitikovkirill,项目名称:zend-shop.com,代码行数:15,代码来源:ShoppingCartHydrator.php

示例9: extract

 /**
  * Converts the given value so that it can be extracted by the hydrator.
  *
  * @param mixed $value The original value.
  * @return mixed Returns the value that should be extracted.
  */
 public function extract($value)
 {
     if (!$value instanceof AddressEntity) {
         throw new \InvalidArgumentException("Invalid address.");
     }
     $hydrator = new ClassMethods(false);
     return $hydrator->extract($value);
 }
开发者ID:continuousphp,项目名称:zoho-subscriptions,代码行数:14,代码来源:AddressStrategy.php

示例10: extract

 public function extract($object)
 {
     if (!$object instanceof SubstanceInterface) {
         throw new \InvalidArgumentException('$object must be an instance of ' . __NAMESPACE__ . '\\SubstanceInterface');
     }
     $data = parent::extract($object);
     return $data;
 }
开发者ID:srayner,项目名称:gallium,代码行数:8,代码来源:SubstanceHydrator.php

示例11: extract

 public function extract($object)
 {
     if (!$object instanceof ProjectInterface) {
         throw new \InvalidArgumentException('$object must be an instance of Application\\Model\\Project\\ProjectInterface');
     }
     $data = parent::extract($object);
     return $data;
 }
开发者ID:srayner,项目名称:gallium,代码行数:8,代码来源:ProjectHydrator.php

示例12: extract

 /**
  * Converts the given value so that it can be extracted by the hydrator.
  *
  * @param mixed $value The original value.
  * @return mixed Returns the value that should be extracted.
  */
 public function extract($value)
 {
     if (!$value instanceof PlanEntity) {
         throw new \InvalidArgumentException('The given value must be a Plan instance.');
     }
     $hydrator = new ClassMethods(true);
     return $hydrator->extract($value);
 }
开发者ID:continuousphp,项目名称:zoho-subscriptions,代码行数:14,代码来源:PlanStrategy.php

示例13: 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

示例14: update

 /**
  * @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);
 }
开发者ID:sydnerdrage,项目名称:sample-service,代码行数:11,代码来源:UserService.php

示例15: extract

 public function extract($object)
 {
     if (!$object instanceof LocationInterface) {
         throw new \InvalidArgumentException('$object must be an instance of ' . __NAMESPACE__ . '\\LocationInterface');
     }
     $data = parent::extract($object);
     unset($data['full_address']);
     return $data;
 }
开发者ID:srayner,项目名称:nickel,代码行数:9,代码来源:LocationHydrator.php


注:本文中的Zend\Stdlib\Hydrator\ClassMethods::extract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。