Skip to content

Commit

Permalink
Merge pull request #526 from teohhanhui/fix-deprecations
Browse files Browse the repository at this point in the history
Fix deprecations
  • Loading branch information
dunglas committed May 5, 2016
2 parents 8c22913 + e26f2c5 commit 1c3e846
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 38 deletions.
26 changes: 14 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,35 @@
],
"require": {
"php": ">=7.0",

"doctrine/inflector": "^1.0",
"psr/cache": "^1.0",
"symfony/http-foundation": "^2.3 || ^3.0 || ^3.1@dev",
"symfony/http-kernel": "^2.8 || ^3.0 || ^3.1@dev",
"symfony/property-info": "^2.8 || ^3.0 || ^3.1@dev",
"symfony/serializer": "^3.1@dev",
"doctrine/inflector": "^1.0",
"willdurand/negotiation": "^2.0"
},
"require-dev": {
"friendsofsymfony/user-bundle": "^2.0@dev",
"behat/behat": "^3.1",
"behat/symfony2-extension": "^2.1",
"behat/mink": "^1.7",
"behat/mink-extension": "^2.2",
"behat/mink-browserkit-driver": "^1.3.1",
"behat/mink-extension": "^2.2",
"behat/symfony2-extension": "^2.1",
"behatch/contexts": "^2.5",
"doctrine/doctrine-bundle": "^1.6@dev",
"doctrine/orm": "^2.2.3",
"friendsofsymfony/user-bundle": "^2.0@dev",
"nelmio/api-doc-bundle": "^2.11.2",
"php-mock/php-mock-phpunit": "^1.1",
"phpdocumentor/reflection-docblock": "^3.0",
"symfony/cache": "^3.1@dev",
"symfony/framework-bundle": "^3.1@dev",
"symfony/dependency-injection": "^2.8 || ^3.0 || ^3.1@dev",
"symfony/finder": "^2.3",
"symfony/framework-bundle": "^3.1@dev",
"symfony/phpunit-bridge": "^3.1@dev",
"symfony/security": "^2.7 || ^3.0",
"symfony/dependency-injection": "^2.8 || ^3.0 || ^3.1@dev",
"symfony/validator": "^2.5 || ^3.0",
"phpdocumentor/reflection-docblock": "^3.0",
"doctrine/orm": "^2.2.3",
"doctrine/doctrine-bundle": "^1.6@dev",
"php-mock/php-mock-phpunit": "^1.1",
"nelmio/api-doc-bundle": "^2.11.2"
"symfony/validator": "^2.5 || ^3.0"
},
"suggest": {
"friendsofsymfony/user-bundle": "To use the FOSUserBundle bridge.",
Expand Down
51 changes: 25 additions & 26 deletions src/Hydra/Serializer/CollectionFiltersNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@
use ApiPlatform\Core\JsonLd\Serializer\ContextTrait;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer;
use Symfony\Component\Serializer\SerializerAwareInterface;
use Symfony\Component\Serializer\SerializerAwareTrait;
use Symfony\Component\Serializer\SerializerInterface;

/**
* Enhance the result of collection by adding the filters applied on collection.
*
* @author Samuel ROZE <samuel.roze@gmail.com>
*/
final class CollectionFiltersNormalizer extends SerializerAwareNormalizer implements NormalizerInterface
final class CollectionFiltersNormalizer implements NormalizerInterface, SerializerAwareInterface
{
use ContextTrait;
use SerializerAwareTrait {
setSerializer as baseSetSerializer;
}

private $collectionNormalizer;
private $resourceMetadataFactory;
private $resourceClassResolver;

/**
* @var FilterCollection
*/
private $filters;

public function __construct(NormalizerInterface $collectionNormalizer, ResourceMetadataFactoryInterface $resourceMetadataFactory, ResourceClassResolverInterface $resourceClassResolver, FilterCollection $filters)
Expand All @@ -47,6 +46,14 @@ public function __construct(NormalizerInterface $collectionNormalizer, ResourceM
$this->filters = $filters;
}

/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null)
{
return $this->collectionNormalizer->supportsNormalization($data, $format);
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -91,6 +98,18 @@ public function normalize($object, $format = null, array $context = [])
return $data;
}

/**
* {@inheritdoc}
*/
public function setSerializer(SerializerInterface $serializer)
{
$this->baseSetSerializer($serializer);

if ($this->collectionNormalizer instanceof SerializerAwareInterface) {
$this->collectionNormalizer->setSerializer($serializer);
}
}

/**
* Returns the content of the Hydra search property.
*
Expand Down Expand Up @@ -123,24 +142,4 @@ private function getSearch(string $resourceClass, array $parts, array $filters)
'hydra:mapping' => $mapping,
];
}

/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null)
{
return $this->collectionNormalizer->supportsNormalization($data, $format);
}

/**
* {@inheritdoc}
*/
public function setSerializer(SerializerInterface $serializer)
{
parent::setSerializer($serializer);

if ($this->collectionNormalizer instanceof SerializerAwareInterface) {
$this->collectionNormalizer->setSerializer($serializer);
}
}
}

0 comments on commit 1c3e846

Please sign in to comment.