本文整理汇总了PHP中Symfony\Component\PropertyAccess\PropertyAccess::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP PropertyAccess::getValue方法的具体用法?PHP PropertyAccess::getValue怎么用?PHP PropertyAccess::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\PropertyAccess\PropertyAccess
的用法示例。
在下文中一共展示了PropertyAccess::getValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: current
/**
* {@inheritdoc}
*/
public function current()
{
$current = $this->iterator->current();
$data = array();
foreach ($this->propertyPaths as $name => $propertyPath) {
$data[$name] = $this->getValue($this->propertyAccessor->getValue($current, $propertyPath));
}
return $data;
}
示例2: current
/**
* {@inheritdoc}
*/
public function current()
{
$current = $this->iterator->current();
$data = array();
foreach ($this->propertyPaths as $name => $propertyPath) {
$data[$name] = $this->getValue($this->propertyAccessor->getValue($current, $propertyPath));
}
$this->query->getDocumentManager()->getUnitOfWork()->detach($current);
return $data;
}
示例3: current
/**
* {@inheritdoc}
*/
public function current()
{
$current = $this->iterator->current();
$data = array();
foreach ($this->propertyPaths as $name => $propertyPath) {
try {
$data[$name] = $this->getValue($this->propertyAccessor->getValue($current[0], $propertyPath));
} catch (UnexpectedTypeException $e) {
//non existent object in path will be ignored
$data[$name] = null;
}
}
$this->query->getEntityManager()->getUnitOfWork()->detach($current[0]);
return $data;
}
示例4: accessValue
/**
* Internal helper method that is used to retrieve an underlying value from a given context (object/array).
* If the given context is scalar, it is returned as the resulting value.
*
* @param mixed $context The context to retrieve the value from.
* @param string $key The property-name/array-key to use in order to read the value from the $context.
*
* @return mixed
*/
protected function accessValue($context, $key)
{
if (is_array($context)) {
return $this->accessor->getValue($context, "[{$key}]");
} elseif (is_object($context)) {
return $this->accessor->getValue($context, $key);
} else {
return $context;
}
}
示例5: addItems
/**
* @param Sitemap $sitemap
* @param $route
* @param array $parametersCollection
* @param array $routeConfigurations
*/
protected function addItems(Sitemap $sitemap, $route, array $parametersCollection, array $routeConfigurations)
{
$progress = new ProgressBar($this->output, count($parametersCollection));
$progress->start();
foreach ($parametersCollection as $parameters) {
$sitemap->addItem($this->router->generate($route, $this->accessor->getValue($parameters, '[route_params]') ?: $parameters, true), $this->accessor->getValue($parameters, '[sitemap_optional_tags][lastmod]') ?: $routeConfigurations['lastmod'], $this->accessor->getValue($parameters, '[sitemap_optional_tags][changefreq]') ?: $routeConfigurations['changefreq'], $this->accessor->getValue($parameters, '[sitemap_optional_tags][priority]') ?: $routeConfigurations['priority']);
$progress->advance();
}
$progress->finish();
$this->output->writeln('');
}
示例6: export
/**
* {@inheritDoc}
*/
public function export(IdentityInterface $identity)
{
if (!$this->handle($identity)) {
throw new Error(sprintf("Trying to handle identity of type '%s' with a factory designed for '%s'", get_class($identity), $this->classFQN));
}
$identityArr = array();
$class = $this->getIdentityReflection($identity);
$methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC);
$properties = $class->getproperties();
foreach ($methods as $method) {
$annotations = $this->reader->getMethodAnnotations($method);
foreach ($annotations as $annotation) {
switch (true) {
case $annotation instanceof Identity:
if (!empty($annotation->name) && $annotation->type == 'getter') {
$identityArr[$annotation->name] = $method->invoke($identity);
}
break;
}
}
}
foreach ($properties as $property) {
$annotations = $this->reader->getPropertyAnnotations($property);
foreach ($annotations as $annotation) {
switch (true) {
case $annotation instanceof Identity:
if (empty($annotation->name)) {
$annotation->name = $property->getName();
}
$identityArr[$annotation->name] = $this->accessor->getValue($identity, $property->getName());
break;
}
}
}
return $identityArr;
}
示例7: getValue
/**
* @param object $entity
* @param string $path
*
* @return mixed
*/
protected function getValue($entity, $path)
{
return $this->accessor->getValue($entity, $path);
}