1<?php 2 3declare(strict_types=1); 4 5namespace JMS\Serializer\GraphNavigator\Factory; 6 7use JMS\Serializer\Accessor\AccessorStrategyInterface; 8use JMS\Serializer\Construction\ObjectConstructorInterface; 9use JMS\Serializer\EventDispatcher\EventDispatcherInterface; 10use JMS\Serializer\Expression\ExpressionEvaluatorInterface; 11use JMS\Serializer\GraphNavigator\DeserializationGraphNavigator; 12use JMS\Serializer\GraphNavigatorInterface; 13use JMS\Serializer\Handler\HandlerRegistryInterface; 14use Metadata\MetadataFactoryInterface; 15 16final class DeserializationGraphNavigatorFactory implements GraphNavigatorFactoryInterface 17{ 18 /** 19 * @var MetadataFactoryInterface 20 */ 21 private $metadataFactory; 22 /** 23 * @var HandlerRegistryInterface 24 */ 25 private $handlerRegistry; 26 /** 27 * @var ObjectConstructorInterface 28 */ 29 private $objectConstructor; 30 /** 31 * @var AccessorStrategyInterface 32 */ 33 private $accessor; 34 /** 35 * @var EventDispatcherInterface 36 */ 37 private $dispatcher; 38 /** 39 * @var ExpressionEvaluatorInterface 40 */ 41 private $expressionEvaluator; 42 43 public function __construct( 44 MetadataFactoryInterface $metadataFactory, 45 HandlerRegistryInterface $handlerRegistry, 46 ObjectConstructorInterface $objectConstructor, 47 AccessorStrategyInterface $accessor, 48 ?EventDispatcherInterface $dispatcher = null, 49 ?ExpressionEvaluatorInterface $expressionEvaluator = null 50 ) { 51 $this->metadataFactory = $metadataFactory; 52 $this->handlerRegistry = $handlerRegistry; 53 $this->objectConstructor = $objectConstructor; 54 $this->accessor = $accessor; 55 $this->dispatcher = $dispatcher; 56 $this->expressionEvaluator = $expressionEvaluator; 57 } 58 59 public function getGraphNavigator(): GraphNavigatorInterface 60 { 61 return new DeserializationGraphNavigator($this->metadataFactory, $this->handlerRegistry, $this->objectConstructor, $this->accessor, $this->dispatcher, $this->expressionEvaluator); 62 } 63} 64