當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。