/** * Generates a cache key based on provided data * * @param mixed $data * * @return string * @throws InvalidArgumentException in case if value was not converted */ public function generate($data) { if ($data instanceof InfoProviderInterface) { $data = $data->getCacheKeyInfo(); } if ($this->converter && !is_string($data)) { $convertedData = $this->converter->convert($data); if ($convertedData === false) { throw new InvalidArgumentException($data); } $data = $convertedData; } elseif (!is_string($data)) { throw new InvalidArgumentException($data); } $cacheKey = $this->normalizer->normalize($data); if ($this->prefix) { return $this->prefix . $cacheKey; } return $cacheKey; }
/** * Test normalize method * @param array $data * * @dataProvider getNormalizeData */ public function testNormalize(array $data) { $entity = $this->createEntity($data); $this->assertEquals($data, $this->normalizer->normalize($entity, $this->format)); }
/** * Test normalize method * @param array $data * * @dataProvider getNormalizeData */ public function testNormalize(array $data) { $entity = $this->createEntity($data); $this->assertEquals($data, $this->normalizer->normalize($entity, $this->format, ['locales' => ['en_US', 'fr_FR']])); }