jmsserializerbundle

JMSSerializerBundle: specify group per attribute

我的梦境 提交于 2019-12-11 13:17:07
问题 I'm using Symfony2 and JMSSerializerBundle to build an API. The system that JMSSerializer provides to set different ways of serializing objects using groups is quite useful, however, I'm missing a way to specify which group do you want to serialize in every parameter. Example: I have an article that is related to a user (author). Articles as well as users can be serialized as "list" or as "details", however, I want the users to be serialized as "list" always that they are retrieved from the

Symfony2 & FOSRestBundle: Getting UUID packed in a BINARY(16) field from MySQL

一曲冷凌霜 提交于 2019-12-11 07:46:48
问题 I am facing a weird problem relating to UUIDs. I have developed a REST API using Symfony2+FOSRestBundle+JMSSerializer. As I need to update some tables from two sources I thought of using UUID as primary key for one entity. I did a doctrine:mapping:import to generate entities in my Symfony project. Everything correct. I ended up with the following entity (only exposing the key field and generated getter for simplicity): <?php namespace Stardigita\TgaAPIBundle\Entity; use Doctrine\ORM\Mapping

Unable to override JMS Serializer's default handler for Symfony ConstraintViolationList

我怕爱的太早我们不能终老 提交于 2019-12-11 04:36:50
问题 I am unable to override default handlers in jms serializer bundle. I'd like to change the way Symfony\Component\Validator\ConstraintViolationList is serialized so I wrote my own custom handler. And tagged it correctly as described in the documentation (and in various stackoverflow answers). However, my handler keeps being overridden by the default handler for ConstraintViolationList that JMS Serializer bundle ships with. I've tagged my handler service correctly. In fact, my handler service is

Jms serializer annotations as yaml file

China☆狼群 提交于 2019-12-11 04:23:12
问题 I've been working on User class inherited from BaseUser of FOSUserBundle , so I've faced a problem. I need to set up serialization for my User but JMS serializer serializes all properties of BaseUser . Solution that I found was to create my own annotation for BaseUser and store it in yaml file, but I don't know how exactly should I do this. 回答1: JMSSerializerBundle by default use your AcmeBundle/Resources/config/serializer directory to fetch all metadata that are declared in yml or xml files.

“Resources are not supported in serialized data.” when using FOSRestBundle and Paginator

喜欢而已 提交于 2019-12-10 22:04:20
问题 I am setting up a REST service for my website with the FOSRestBundle and JMSSerializerBundle. I made a custom method on a entity repository which returns a Paginator object. The method works great when I use it on the normal website, but when I want to use the method with the REST route, this error is thrown (XML or JSON output throws the same error) : "Resources are not supported in serialized data." I really don't know where to search since the error isn't very explicit to me. Here's my

Using JMSSerialize to serialize Doctrine2 Entities that follow SimplifiedYamlDriver convention

坚强是说给别人听的谎言 提交于 2019-12-10 20:14:26
问题 The symfony sponsored project \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver is really useful in my project to keep Entity file names clean and simple. However, JMSSerialize assumes that the naming convention for each Entity is the fully qualified namespace. This is not true when using \Doctrine\ORM\Mapping\Driver\SimplifiedYamlDriver in your Doctrine2 Configuration. (http://docs.doctrine-project.org/en/latest/reference/yaml-mapping.html) <?php $namespaces = array( '/path/to/files1' =>

Deserializing XML array

独自空忆成欢 提交于 2019-12-10 11:16:42
问题 I'm using an API that returns XML. I can retrieve one or multiple accounts with the API. I am using the Jms Serializer to deserialize this data into simple model classes that will hold the data. An account looks like <account href="https://your-subdomain.recurly.com/v2/accounts/1"> ... <account_code>1</account_code> <state>active</state> <username nil="nil"></username> <email>verena@example.com</email> <first_name>Verena</first_name> <last_name>Example</last_name> ... <address>...</address> <

JMS Serializer serialize object in object with diffrent view

心不动则不痛 提交于 2019-12-08 08:19:42
问题 I'm developing a RESTful service with Symfony2, JMS Serializer Bundle, FOS Rest Bundle and Hateoas Bundle. There are 2 entities User and Company and I want to, when I serialize a Company get larger detail. But, when serializing User related Company show only Company ID and name object or just ID as integer. I have serialize policy like below. User Acme\UserBundle\Entity\User: exclusion_policy: ALL xml_root_name: user properties: id: expose: true type: integer company: expose: true type: Acme

JMSSerializer + forms/arrays

风流意气都作罢 提交于 2019-12-07 13:14:06
问题 I'm rather newcomer into SF2 community, so please, take it easy ;) I've faced an issue with JMSSerializerBundle and forms/arrays. I've spent two days trying to figure it out myself, without any success and I've decided to post this to the Group. I'm building a simple test application that will allow me to understand how the stuff works. Now it's time for API. I'm using FOSRestBundle, works perfectly. My whole "application" is working perfectly (development was really fast and effective), I've

How to make JMS Serializer throw an exception on deserializing JSON instead of coercing types?

╄→гoц情女王★ 提交于 2019-12-07 04:24:56
问题 I'm trying to write a REST API which consumes a JSON from a PUT request in Symfony2. Deserializing the JSON to an entity sort of works – but the JMS Serializer seems to coerce types from the JSON instead of throwing an exception if the type of a property in the JSON does not match the entity’s corresponding property. For example … { "id" : "123" } … will result in … int(123) … if the property id is defined as an integer in the entity. But I would like JMS Serializer to throw an exception