示例#1
0
 public function configureSerializerExtension(JMSSerializerExtension $ext)
 {
     $ext->addHandlerFactory(new ArticleAuthorHandlerFactory());
     $ext->addHandlerFactory(new ArticleCommentsLinkHandlerFactory());
     $ext->addHandlerFactory(new AuthorImageUriHandlerFactory());
     $ext->addHandlerFactory(new PackageItemsLinkHandlerFactory());
     $ext->addHandlerFactory(new ItemLinkHandlerFactory());
     $ext->addHandlerFactory(new TopicArticlesLinkHandlerFactory());
     $ext->addHandlerFactory(new ArticleFieldsHandlerFactory());
     $ext->addHandlerFactory(new ArticleTranslationsHandlerFactory());
     $ext->addHandlerFactory(new ArticleRenditionsHandlerFactory());
 }
示例#2
0
 public function configureSerializerExtension(JMSSerializerExtension $ext)
 {
     $ext->addHandlerFactory(new ObjectBasedFactory());
     $ext->addHandlerFactory(new DoctrineProxyFactory());
     $ext->addHandlerFactory(new ArrayCollectionFactory());
     $ext->addHandlerFactory(new ConstraintViolationFactory());
     $ext->addHandlerFactory(new DateTimeFactory());
     $ext->addHandlerFactory(new FormErrorFactory());
 }
示例#3
0
 private function getSerializer()
 {
     $container = new ContainerBuilder();
     $container->set('annotation_reader', new AnnotationReader());
     $container->set('translator', new IdentityTranslator(new MessageSelector()));
     $container->setParameter('kernel.debug', true);
     $container->setParameter('kernel.cache_dir', sys_get_temp_dir());
     $container->setParameter('kernel.bundles', array());
     $extension = new JMSSerializerExtension();
     $extension->load(array(array()), $container);
     $bundle = new JMSSerializerBundle();
     $bundle->build($container);
     $container->getCompilerPassConfig()->setOptimizationPasses(array(new ResolveDefinitionTemplatesPass()));
     $container->getCompilerPassConfig()->setRemovingPasses(array());
     $container->compile();
     return $container->get('serializer');
 }