Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glaphire/c12528ad90c5f49873780b2705f89286 to your computer and use it in GitHub Desktop.
Save glaphire/c12528ad90c5f49873780b2705f89286 to your computer and use it in GitHub Desktop.
<?php
namespace App\Serializer\Normalizer;
use App\Pagination\PaginatedCollection;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
class PaginatedCollectionNormalizer extends PropertyNormalizer implements NormalizerInterface
{
/**
* {@inheritdoc}
*
* @param array $context options that normalizers have access to
*/
public function supportsNormalization($object, string $format = null, array $context = [])
{
//Я не знаю что тут сделать, чтобы объект нормализировался корректно
$data = $this->normalizer->normalize($object, $format, $context);
return $data;
}
public function normalize($object, string $format = null, array $context = [])
{
return $object instanceof PaginatedCollection;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment