Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#2218 from marc-mabe/ca…
Browse files Browse the repository at this point in the history
…che_optimisations

Cache: Minimized comparisons on getting serializer of serializer plugin
  • Loading branch information
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Storage/Plugin/PluginOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,16 @@ public function setSerializer($serializer)
*/
public function getSerializer()
{
if (is_string($this->serializer)) {
$options = $this->getSerializerOptions();
$this->setSerializer(SerializerFactory::factory($this->serializer, $options));
} elseif (null === $this->serializer) {
$this->setSerializer(SerializerFactory::getDefaultAdapter());
if (!$this->serializer instanceof SerializerAdapter) {
// use default serializer
if (!$this->serializer) {
$this->setSerializer(SerializerFactory::getDefaultAdapter());
// instantiate by class name + serializer_options
} else {
$options = $this->getSerializerOptions();
$this->setSerializer(SerializerFactory::factory($this->serializer, $options));
}
}

return $this->serializer;
}

Expand Down

0 comments on commit f51678c

Please sign in to comment.