Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecations #526

Merged
merged 2 commits into from
May 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}