Skip to content

Commit

Permalink
Merge pull request #14 from mxr576/fixes
Browse files Browse the repository at this point in the history
Small code style and logic fixes
  • Loading branch information
mxr576 authored Aug 9, 2018
2 parents 8017c39 + c1bb4b6 commit 7606137
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/Api/Management/Denormalizer/AppDenormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class AppDenormalizer extends EntityDenormalizer
public function denormalize($data, $class, $format = null, array $context = [])
{
if (isset($data->developerId)) {
return parent::denormalize($data, $this->developerAppClass);
return parent::denormalize($data, $this->developerAppClass, $format, $context);
} elseif (isset($data->companyName)) {
return parent::denormalize($data, $this->companyAppClass);
return parent::denormalize($data, $this->companyAppClass, $format, $context);
}
throw new UnexpectedValueException(
'Unable to denormalize because both "developerId" and "companyName" are missing from data.'
Expand All @@ -68,6 +68,6 @@ public function supportsDenormalization($data, $type, $format = null)
return false;
}

return AppInterface::class === $type || $type instanceof AppInterface || in_array($type, class_implements(AppInterface::class));
return AppInterface::class === $type || $type instanceof AppInterface || in_array(AppInterface::class, class_implements($type));
}
}
3 changes: 1 addition & 2 deletions src/Controller/EntityListingControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ protected function responseArrayToArrayOfEntities(array $responseArray, string $

foreach ($responseArray as $item) {
/** @var \Apigee\Edge\Entity\EntityInterface $tmp */
$tmp = $this->getEntitySerializer()->denormalize($item,
$this->getEntityClass());
$tmp = $this->getEntitySerializer()->denormalize($item, $this->getEntityClass());
$entities[$tmp->{$keyGetter}()] = $tmp;
}

Expand Down
24 changes: 24 additions & 0 deletions src/Normalizer/EntityNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@
*/
class EntityNormalizer implements NormalizerInterface, SerializerAwareInterface
{
/**
* @var null|\Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface
*/
protected $classMetadataFactory;

/**
* @var null|\Symfony\Component\Serializer\NameConverter\NameConverterInterface
*/
protected $nameConverter;

/**
* @var null|\Symfony\Component\PropertyAccess\PropertyAccessorInterface
*/
protected $propertyAccessor;

/**
* @var null|\Symfony\Component\PropertyInfo\PropertyInfoExtractor|\Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface
*/
protected $propertyTypeExtractor;

/** @var \Symfony\Component\Serializer\Normalizer\ObjectNormalizer */
private $objectNormalizer;

Expand Down Expand Up @@ -75,6 +95,10 @@ public function __construct(ClassMetadataFactoryInterface $classMetadataFactory
]
);
}
$this->classMetadataFactory = $classMetadataFactory;
$this->nameConverter = $nameConverter;
$this->propertyAccessor = $propertyAccessor;
$this->propertyTypeExtractor = $propertyTypeExtractor;
$this->objectNormalizer = new ObjectNormalizer($classMetadataFactory, $nameConverter, $propertyAccessor, $propertyTypeExtractor);
}

Expand Down

0 comments on commit 7606137

Please sign in to comment.