FAQ Database Discussion Community


Deserializing or parse XML response in Symfony2

php,xml,symfony2,deserialization,jmsserializerbundle
I am calling a API method through cURL and I got this response: <?xml version="1.0" encoding="UTF-8"?> <jobInfo xmlns="http://www.force.com/2009/06/asyncapi/dataload"> <id>75080000002s5siAAA</id> <operation>query</operation> <object>User</object> <createdById>00580000008ReolAAC</createdById> <createdDate>2015-06-23T13:03:01.000Z</createdDate> <systemModstamp>2015-06-23T13:03:01.000Z</systemModstamp> <state>Open</state>...

Include a method when object is serialized in JMS

symfony2,serialization,jmsserializerbundle
I have a method that returns a value: /** * @ORM\Table() * @ORM\Entity(repositoryClass="PersonRepository") */ class Person { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; public function getFoo(){ return $this->id + 1; } //setters & getters } I would like to include the...

Add a root element name using JMS Serializer with Symfony 2.6

symfony2,fosrestbundle,jmsserializerbundle,jms-serializer,symfony-2.6
I have implemented web services using Symfony 2.6 with FOSRestBundle and JMSSerializerBundle. I can't manage to have a root element named request eventhough I put xml_root_name: request in the configuration file. I have a config\serializer\Entity.Request.yml file with the following information: Tvjp\RequestBundle\Entity\Request: exclusion_policy: ALL xml_root_name: request properties: id: expose: true type:...

Can't serialize virtual properties in schmittjoh/serializer

php,jmsserializerbundle,jms-serializer
One of my classes that I'm serializing has a virtual property that I would like to see. I'm using yaml configuration. Here's the yaml: Namespace\Model\Keg: exclusion_policy: ALL properties: A list of properties that work virtual_properties: getKegImage: serialized_name: image Here's the class: namespace Namespace\Model; class Keg extends ModelAbstract { /** Some...

JMSSerializerBundle, Deserialize doesn't Relationship After Persist

php,symfony2,doctrine,deserialization,jmsserializerbundle
Deserialization process OneToMany-ManyToOne process always get relation data sets NULL. The Result Entity: @ORM\OneToMany(targetEntity="\Acme\DemoBundle\Entity\AnswerContent", mappedBy="answerResult", cascade={"persist", "remove"}, orphanRemoval=true) @JMS\Type("ArrayCollection<Acme\DemoBundle\Entity\AnswerContent>") @JMS\Groups({"survey_answer_fetching"}) The Answer Entity: @ORM\ManyToOne(targetEntity="Acme\DemoBundle\Entity\AnswerResult", inversedBy="answers") @ORM\JoinColumn(name="answer_result_id",...

JMSSerializerBundle: the annotation '@Enum' in property Doctrine\ORM\Mapping\GeneratedValue::$strategy was never imported

symfony2,jmsserializerbundle
Im gettig this error: The annotation '@Enum' in property Doctrine\ORM\Mapping\GeneratedValue::$strategy was never imported. Did you maybe forget to add a 'use' statement for this annotation? Im just trying to serialize a paginator object: $paginator = new Paginator($query, $fetchJoinCollection = true); $serializer = \JMS\Serializer\SerializerBuilder::create()->build(); $jsonContent = $serializer->serialize($paginator, 'json'); These are my...

JMS Serializer - deserialize a non-recurrent node structure in xml

symfony2,xml-deserialization,jmsserializerbundle
I use jms serializer bundle for deserializing xml into objects in my sf2 project. I didn't had any problem for creating all my models until I have to add this field : <parent_property> <child_property_1> <![CDATA[ value ]]> </child_property_1> <child_property_1> <![CDATA[ value ]]> </child_property_1> <child_property_1> <![CDATA[ value ]]> </child_property_1> <child_property_2> <![CDATA[...

Jms serializer @JMS\Inline() annotation overrides an actual id

php,symfony2,doctrine2,jmsserializerbundle,jms-serializer
I have product and product_detail tables in database. Every product has a product detail. class Product { /** * @var ProductDetail * @JMS\ReadOnly() * @ORM\OneToOne(targetEntity="ApiBundle\Entity\ProductDetail", mappedBy="product", cascade={"persist"}) * @JMS\Inline() */ private $detail; } I use @JMS\Inline() annotation to show only detail information of product_detail table. But when I serialize a...

jms serializer bundle serialize super class

symfony2,jmsserializerbundle
I use jms serializer bundle to serialize a super class but i want to serialize my super class like this: /** * @Discriminator(field = "type", map = {"vehicle": "Vehicle", "car": "Car", "moped": "Moped"}) */ class Vehicle { } class Car extends Vehicle { } class Moped extends Vehicle { }...