/**
  * {@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;
 }
 /**
  * {@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;
 }
 /**
  * {@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;
 }
Esempio n. 4
0
 /**
  * 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;
     }
 }
 /**
  * @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('');
 }
 /**
  * {@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;
 }
Esempio n. 7
0
 /**
  * @param object $entity
  * @param string $path
  *
  * @return mixed
  */
 protected function getValue($entity, $path)
 {
     return $this->accessor->getValue($entity, $path);
 }