Symfony\Component\Serializer\Serializer::__construct PHP Method

__construct() public method

public __construct ( array $normalizers = [], array $encoders = [] )
$normalizers array
$encoders array
    public function __construct(array $normalizers = array(), array $encoders = array())
    {
        foreach ($normalizers as $normalizer) {
            if ($normalizer instanceof SerializerAwareInterface) {
                $normalizer->setSerializer($this);
            }
        }
        $this->normalizers = $normalizers;

        foreach ($encoders as $encoder) {
            if ($encoder instanceof SerializerAwareInterface) {
                $encoder->setSerializer($this);
            }
        }
        $this->encoders = $encoders;
    }

Usage Example

 /**
  * Constructor
  *
  * @param EntityManager $entityManager
  * @param array $normalizers
  * @param array $encoders
  */
 public function __construct(EntityManager $entityManager, array $normalizers = array(), array $encoders = array())
 {
     $this->entityManager = $entityManager;
     parent::__construct($normalizers, $encoders);
     foreach ($this->normalizers as $normalizer) {
         if ($normalizer instanceof DoctrineEntitySerializerAwareInterface) {
             $normalizer->setSerializer($this);
         }
     }
 }
All Usage Examples Of Symfony\Component\Serializer\Serializer::__construct