コード例 #1
0
 protected function buildSerializer()
 {
     $registry = new SerializerRegistry();
     $registry->add(new DateTimeSerializer());
     $builder = new ObjectSerializerGenerator(new ReflectionRegistry());
     $cache = new ArrayCache();
     $locator = new SerializerLocator($registry, $builder, $cache);
     return new Serializer($locator);
 }
コード例 #2
0
 /**
  * @return Serializer
  */
 public function createSerializer()
 {
     $registry = new SerializerRegistry();
     $registry->add(new DateTimeSerializer());
     $registry->add(new DateTimeImmutableSerializer());
     $serializer = new Serializer(new EventManager());
     $serializer->attach(new ObjectTypeListener());
     $serializer->attach(new ObjectListener(new SerializerLocator($registry, new ObjectSerializerGenerator(new AnnotationBackedPropertyInfo()), new ArrayCache('Serializer'))));
     return $serializer;
 }