Skip to content

Commit

Permalink
Fix for setIgnoredAttributes() method is deprecated (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
divya-intelli authored and giteshk committed May 23, 2023
1 parent cdb473b commit 29a0110
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Api/Management/Query/StatsQueryNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
namespace Apigee\Edge\Api\Management\Query;

use Apigee\Edge\Serializer\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;
Expand All @@ -44,7 +45,6 @@ class StatsQueryNormalizer implements NormalizerInterface
public function __construct()
{
$this->objectNormalizer = new ObjectNormalizer();
$this->objectNormalizer->setIgnoredAttributes(['timeRange']);
$this->serializer = new Serializer([$this->objectNormalizer], [new JsonEncoder()]);
}

Expand All @@ -55,7 +55,7 @@ public function normalize($object, $format = null, array $context = [])
{
/** @var StatsQueryInterface $object */
// Transform the object to JSON and back to an array to keep boolean values as boolean.
$json = $this->serializer->serialize($object, 'json');
$json = $this->serializer->serialize($object, 'json', [AbstractNormalizer::IGNORED_ATTRIBUTES => ['timeRange']]);
$data = $this->serializer->decode($json, 'json');
// Replace metrics with the required query parameter name and value.
$data['select'] = implode(',', $data['metrics']);
Expand Down

0 comments on commit 29a0110

Please sign in to comment.