jmsserializerbundle

JMSSerializer stand alone - Annotation does not exist, or cannot be auto-loaded

一笑奈何 提交于 2019-11-28 18:36:42
I am attempting to use JMSSerializer as a stand alone library to map JSON responses from an API to my model classes and am running into some issues. Executing the following code results in an exception: <?php require dirname(__DIR__) . '/vendor/autoload.php'; use JMS\Serializer\Annotation AS JMS; class Trii { /** * User ID for this session * @JMS\SerializedName("userID") * @JMS\Annotation(getter="getUserId") * @JMS\Type("string") * @var string */ private $userId; public function getUserId() { return $this->userId; } public function setUserId($userId) { $this->userId = $userId; } } $serializer

how to update symfony2/doctrine entity from a @Groups inclusion policy JMSSerializer deserialized entity

妖精的绣舞 提交于 2019-11-28 07:41:24
I'm trying to update symfony2/doctrine entities using JMSSerializer with an @ExclusionPolicy:None @Groups Inclusion Policy. * @Serializer\ExclusionPolicy("none") */ class Foo { /** * @Serializer\Groups({"flag","edit"}) */ protected $id; /** * @Serializer\Groups({"edit"}) */ protected $name; /** * @Serializer\Groups({"flag"}) */ protected $flag; /** * @Serializer\Exclude() */ protected $createdBy; } reference: http://jmsyst.com/libs/serializer/master/reference/annotations the result for the following record: Foo (id:1, name:'bar', flagged:false ,created_by:123) is serialized using Group

JMSSerializer deserialize entity by id

最后都变了- 提交于 2019-11-28 03:57:58
问题 i'm using JMSSerializer to deserialize a JSON request and i'm having troubles with ManyToOne relations. I would like to deserialize the relation entity from a id given. Example: Class Game { /** * @var Team * * @ORM\ManyToOne(targetEntity="Team") * @ORM\JoinColumn(name="home_team_id", referencedColumnName="id") * @JMSSerializer\SerializedName("home") */ private $homeTeam; /** * @ORM\ManyToOne(targetEntity="Team") * @ORM\JoinColumn(name="visitor_team_id", referencedColumnName="id") *

Disable Doctrine 2 lazy loading when using JMS Serializer?

夙愿已清 提交于 2019-11-27 20:12:38
Im using Doctrine 2 ORM in my Zend project and need to serialize my Entities to JSON in several cases. ATM i use the Querybuilder and join all tables i need. But my serializer causes doctrine to lazy load every associated Entity which results in pretty huge data amounts and provokes recursion. Now im looking for a way to totally disable Doctrines lazy loading behavior. My way to select data would be the following: $qb= $this->_em->createQueryBuilder() ->from("\Project\Entity\Personappointment", 'pa') ->select('pa', 't', 'c', 'a', 'aps', 'apt', 'p') ->leftjoin('pa.table', 't') ->leftjoin('pa

JMSSerializerBundle. no control over third party meta data

廉价感情. 提交于 2019-11-27 19:04:59
I have two entities I wish to serialize with the JMSSerializerBundle. The Music Entity has a mapping-file with exclusion_policy: NONE . The Music entity has a field of the entity User from FOSUserBundle . The User entity has a mapping-file with exclusion_policy: ALL with a few fields set to expose: true , so they will be serialized. The problem is, the User field gets fully serialized. It does not matter if I change the mapping-file of the User entity. This is how it looks: #My/Bundle/Resources/config/serializer/Entity.Music.yml xxx\xxx\Entity\Music: exclusion_policy: NONE #My/Bundle/Resources

Symfony2, FOSRestBundle. How to use group with JMSSerializerBundle?

浪子不回头ぞ 提交于 2019-11-27 18:18:01
问题 I have entity: <?php namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation\Groups; //... /** * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository") **/ class User extends BaseUser { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") * @Groups({"default"}) */ protected $id; /** * @ORM\ManyToMany(targetEntity="StorageBundle\Entity\File") * @ORM\JoinTable(name="users_photos", * joinColumns={@ORM\JoinColumn(name=

Disable Doctrine 2 lazy loading when using JMS Serializer?

谁说胖子不能爱 提交于 2019-11-26 22:55:10
问题 Im using Doctrine 2 ORM in my Zend project and need to serialize my Entities to JSON in several cases. ATM i use the Querybuilder and join all tables i need. But my serializer causes doctrine to lazy load every associated Entity which results in pretty huge data amounts and provokes recursion. Now im looking for a way to totally disable Doctrines lazy loading behavior. My way to select data would be the following: $qb= $this->_em->createQueryBuilder() ->from("\Project\Entity\Personappointment

JMSSerializerBundle. no control over third party meta data

本秂侑毒 提交于 2019-11-26 15:54:53
问题 I have two entities I wish to serialize with the JMSSerializerBundle. The Music Entity has a mapping-file with exclusion_policy: NONE . The Music entity has a field of the entity User from FOSUserBundle . The User entity has a mapping-file with exclusion_policy: ALL with a few fields set to expose: true , so they will be serialized. The problem is, the User field gets fully serialized. It does not matter if I change the mapping-file of the User entity. This is how it looks: #My/Bundle