jmsserializerbundle

JMS Serializer: How to limit the depth of serialisation for an object graph

风流意气都作罢 提交于 2019-12-19 04:12:13
问题 Maybe it is just my misunderstanding of this annotation however it does not seam to work as expected. I have the following object graph User -> Company -> Users -> Groups -> Permissions As you can see there will be some recursion. JMS handles this quite well by not serialising the other user's company properties as well as not the current user. However I want the serialization to stop at and include company. I have tried this expecting that once the level $context->level = 2 it would stop <

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

不羁的心 提交于 2019-12-17 22:23:28
问题 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() {

Symfony2 “@Type” in property Genius\ProfileBundle\Entity\Profil::$actualites was never imported [closed]

让人想犯罪 __ 提交于 2019-12-13 22:01:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am new to Symfony2 in general. This issue relates to JMS Serializer annotations and FOSRestBundle though. I have the following Profile.php Entity with an Actualite Field that i'm looking to set them as an Array through Type Annotation. class Profile { ... /** * @ORM\OneToMany(targetEntity="Genius\ProfileBundle

Symfony: How to make JMS Serializer works with strict types?

痴心易碎 提交于 2019-12-13 13:23:08
问题 This is my situation: I'm trying to write a Symfony REST API that works with "strict" types (integer, boolean and float), because default Symfony behaviour doesn't support it and I want to avoid force cast types (e.g: JMS Serializer converts string value into integer field type) To do this, I have created a custom handler which implements the JMS\Serializer\Handler\SubscribingHandlerInterface (e.g a StrictIntegerHandler ): <?php namespace AppBundle\Serializer; use JMS\Serializer\Context; use

FOSRestBundle & JMSSerializer : Wrong Json Response [closed]

一个人想着一个人 提交于 2019-12-13 09:37:16
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . In the same response i get a field as object and a field as Array, how can i correct this ? Note i don't controle the building of my response because i'm using JMSSerializer CODE (Edit 1) \Entity\Profil.php class Profil { ... /** * Get actualites * * @return \Doctrine\Common\Collections\Collection */ public

JMSSerializerbundle @expose relationship, ignores other entities policies

家住魔仙堡 提交于 2019-12-13 04:34:48
问题 I have 2 Entities. A StockItem, and a User. They look like this. /** * StockItem * * @ORM\Table() * * @ORM\Entity(repositoryClass="IREnterprise\AppBundle\Entity\StockItemRepository") * @ORM\HasLifecycleCallbacks * * @ExclusionPolicy("all") * */ class StockItem { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") * @Expose */ private $id; /** * @ORM\ManyToOne(targetEntity="IREnterprise\UserBundle\Entity\User", inversedBy="stockItems")

JMSSerializerBundle mixing auto detection and explicit directories?

时光总嘲笑我的痴心妄想 提交于 2019-12-12 03:29:15
问题 Is it possible to use auto_detection for some bundles, while overriding the location of third-party models by specifying directories for them? I've been playing with the JMSSerializerBundle the past couple of days trying to understand it and get it to work with a personal project, and it doesn't look like there is any way to use auto_detection as well as specify directories for third-party metadata. If I write my FOSUserBundle Model.User.yml serialization data, e.g.: FOS\UserBundle\Model\User

ReflectionException in JMS

試著忘記壹切 提交于 2019-12-12 01:27:37
问题 I am developing a simple app in symfony to learn symfony.It has Terms,Example entities.TermExamples is one more entity is one more entitty which is a mapping table between Term and Examples.All is fine but when i try to serialize using JMS serializer ,I get a Reflection exception These are my entities Term /** * Term * * @ORM\Table(name="terms") * @ORM\Entity */ class Term { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */

How to use JMSSerializer with symfony 4.2

耗尽温柔 提交于 2019-12-11 17:21:28
问题 i am building an Api with symfony 4.2 and want to use jms-serializer to serialize my data in Json format, after installing it with composer require jms/serializer-bundle and when i try to use it this way : ``` demands = $demandRepo->findAll(); return $this->container->get('serializer')->serialize($demands,'json');``` it gives me this errur : Service "serializer" not found, the container inside "App\Controller\DemandController" is a smaller service locator that only knows about the "doctrine",

JMSSerializer Bundle - Circular Reference Error (Only on Prod Azure Environment) - Symfony4/Doctrine2 REST API

梦想的初衷 提交于 2019-12-11 14:49:43
问题 So I know somewhat similar issues have been discussed numerous times before but I haven't had any luck finding a solution with this specific issue. Running locally (using MAMP) I have no issues with my API responses. However once deployed to the production Azure server (via Ansible) I run into the dreaded error: request.CRITICAL: Uncaught PHP Exception Symfony\Component\Serializer\Exception\CircularReferenceException: "A circular reference has been detected when serializing the object of