fosrestbundle

JMS Serializer DateTime not deserializing?

做~自己de王妃 提交于 2020-01-06 20:09:31
问题 I have a sort of special setup of Symfony2, FOSRestBundle and JMSSerializerBundle, due to a legacy DB in the background. I'm struggling to get a PUT request working, including the deserialization of a DateTime property. First things first. This is a model snippet, notice the DateTime format: /** * @var \DateTime * * @ORM\Column(name="sys_lastmodifieddate", type="datetime", nullable=true) * * @Type("DateTime<'Y-m-d\TH:i:sP'>") * * @Expose */ private $sysLastmodifieddate; I have built a Form

Subrequests with post vars

一笑奈何 提交于 2020-01-03 06:33:10
问题 Here's the big picture: I am writing a symfony2 bundle for my web application. This application consists in a standard website with CRUD controllers. And on the other side it contains a rest api that also manages creation/edit/... on entities. I started writing the Rest\UserController for the User entity. It contains all standard REST actions (GET, POST, PUT, DELETE). It is based on the very good tutorial by William Durand: http://williamdurand.fr/2012/08/02/rest-apis-with-symfony2-the-right

symfony 2.7.13 JMS Serializer customization of 3rd-party bundles query problems

流过昼夜 提交于 2020-01-02 10:35:21
问题 I try to customize my jms serializer config and copy the xml config of SonataMediaBundle to my local config. The requests are in a Controller that extends FOSRestBundle in a Symfony 2.7.13 application with sonata-project bundles. My current issue is, that I have a very long execution time due to a pool of thousands queries. If I use the default serializer config of the sonataMediaBundle I only have one query. config.yml: jms_serializer: metadata: auto_detection: false directories: FOSUB:

Every parent controller must have `get{SINGULAR}Action($id)` method when i have multi level sub resource in FOS Rest Bundle

只愿长相守 提交于 2020-01-01 09:33:14
问题 I have three controller named BlogController , PostController , CommentController that CommentController is sub resource of PostController and PostController sub resource of BlogController . /** * @Rest\RouteResource("blog", pluralize=false) */ class BlogController extends FOSRestController { public function getAction($blogUri) { ... } } /** * @Rest\RouteResource("post", pluralize=false) */ class PostController extends FOSRestController { public function getAction($postId) { ... } } /** *

FOSOAuthServerBundle: Invalid grant_type parameter or parameter missing

风流意气都作罢 提交于 2019-12-25 04:26:59
问题 I'm trying to build a REST API using Symfony 3.1 and the FOSRestBundle, FOSUserBundle and FOSOAuthServerBundle. I managed to achieve this following the guide at https://gist.github.com/tjamps/11d617a4b318d65ca583. I'm now struggling at the authentication process. When I make a POST request to the server for authentication (to localhost:8000/oauth/v2/token) with the parameters encoded in json in the request body: { "grant_type": "password", "client_id": "1_myveryverysecretkey", "client_secret"

Exclude some attributes from relational entity RestBundle Symfony2

假装没事ソ 提交于 2019-12-25 03:13:30
问题 I want to exclude some attributes when I return an object with relations. For example, I have an entity Users and Album and I just want to expose the username when I get a list of Album. Is it possible ? Here is my Album entity : <?php namespace Billion\AlbumBundle\Entity; use Billion\AlbumBundle\Entity\Media; use Doctrine\ORM\Mapping as ORM; /** * Album * * @ORM\Table() * @ORM\Entity */ class Album { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM

FOSRestBundle update only one field at a time using PUT

本小妞迷上赌 提交于 2019-12-25 03:06:44
问题 While ago I have asked same question Symfony PUT does not contain all entity properties mapped and I've got some #hack solution to solve the problem but when the form is more complex, contains choices (arrays) or mapped entities (objects) the solution is not applicable anymore. So I came up with very dirty ideas to make it work such as if(is_object($event->getForm()->getData())) $event->setData($event->getForm()->getData()->getId()); if(is_array($event->getData()) && empty($event->getData()))

Doctrine2 ORM Ignore relations in Merge

徘徊边缘 提交于 2019-12-25 02:35:10
问题 I'm implementing a REST Api with FOSRestBundle and I have encountered a problem with the modification of existing entity (PUT) I have a class Student with has a ManyToOne relation /** * @JMS\MaxDepth(2) * @ORM\ManyToOne(targetEntity="ClassRoom", inversedBy="students") * @ORM\JoinColumn(name="classroom_id", referencedColumnName="id") */ protected $classRoom; When performing a PUT action I only receive the value attributes since i do not want to let the user modify the relations via a put

FOSRestBundle + Symfony 3.4 : rest type not reconized

寵の児 提交于 2019-12-24 09:26:45
问题 I'm using Symfony 3.4 with FOSUserBundle, I have imported my project from Symfony 3.3, and now, I have an error : Class could not be determined for Controller identified by "api.yaml" in api.yaml (which is being imported from "/home/user/project/config/routes.yaml"). Make sure there is a loa der supporting the "rest" type. Here my config/routes.yaml file : # Some routes... # Api rest api: type: rest resource: "api.yaml" prefix: /api And my file config/api.yaml : rest.media: type: rest

Routes not found in PhpStorm, Symfony2 and FOSRestBundle

微笑、不失礼 提交于 2019-12-24 06:18:11
问题 I'm using latest PhpStorm with the Symfony2 plugin on a Symfony 3.2 project and FOSRestBundle. The routes generated by the FOSRestBundle don't get resolved automatically in PhpStorm (you get "missing route") although the routes work fine and show up with php bin/console debug:router Has anyone found a trick to get them to show as good routes? It's not blocking me from anything, just a visual thing. Update: Appears to be working except for explicitly named routes. I had forgotten (or not