/** * 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); } } }
public function __construct(array $transformers = array(), array $encoders = array()) { foreach ($transformers as $transformer) { if (!$transformer instanceof SerializedClassInterface) { $message = sprintf('Transformer %s must implement %s', get_class($transformer), SerializedClassInterface::CLASS_NAME); throw new UnexpectedValueException($message); } } parent::__construct($transformers, $encoders); }
/** * @param EncoderInterface[] $encoders */ public function __construct(array $encoders = []) { $normalizers = [new ResultSetNormalizer(), new ItemNormalizer(), new StatsNormalizer()]; parent::__construct($normalizers, $encoders); }
public function __construct(array $normalizers = array(), array $encoders = array()) { $normalizers = array_merge($normalizers, array(new EntityNormalizer())); $encoders = array_merge($encoders, array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(), new \Symfony\Component\Serializer\Encoder\XmlEncoder(), new YamlEncoder())); return parent::__construct($normalizers, $encoders); }