本文整理汇总了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;
}
示例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));
}
示例3: extract
public function extract($items)
{
$data = [];
foreach ($items as $item) {
$data[] = $this->hydrator->extract($item);
}
return $data;
}
示例4: extract
public function extract($object)
{
$classMethods = new ClassMethods();
$properties = $classMethods->extract($object);
unset($properties['alternative']);
return $properties;
}
示例5: extract
public function extract($object)
{
$values = parent::extract($object);
unset($values['arrayCopy']);
// remove if null
return array_filter($values);
}
示例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;
}
示例7: toArray
public function toArray()
{
$hydrator = new Hydrator\ClassMethods();
$hydrator->setUnderscoreSeparatedKeys(false);
$res = $hydrator->extract($this);
return $res;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}