public function extract($value, ExtractionContext $context = null)
 {
     if (!is_object($value)) {
         return $value;
     }
     return $this->hydrator->extract($value);
 }
示例#2
0
 /**
  * {@inheritDoc}
  */
 public function hydrate($value, $property, HydrationContext $context = null)
 {
     if (is_array($value)) {
         $property = $this->namingStrategy->getNameForHydration($property, $context);
         $method = 'get' . $property;
         $object = $context->object->{$method}();
         return $this->hydrator->hydrate($value, $object);
     }
     return $value;
 }
 public function extract($value, ExtractionContext $context = null)
 {
     if (!is_array($value)) {
         return $value;
     }
     $collection = [];
     foreach ($value as $item) {
         $collection[] = $this->hydrator->extract($item);
     }
     return $collection;
 }
示例#4
0
 public function extract($object)
 {
     $data = $this->hydrator->extract($object);
     $filtered = [];
     foreach ($this->extractKeys as $k) {
         if (!isset($data[$k])) {
             continue;
         }
         $filtered[$k] = $data[$k];
     }
     return $filtered;
 }
 /**
  *
  * @dataProvider extractProvider
  */
 public function testExtract(HydratorInterface $hydrator, $objFunc, array $expData)
 {
     $extractedData = $hydrator->extract($objFunc());
     $this->assertSame($expData, $extractedData);
 }