fosrestbundle

POST request on many-to-many association

余生长醉 提交于 2021-02-16 15:27:10
问题 I have two entities with a many-to-many association: class User extends BaseUser and class Calendar { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="text") */ private $name; /** * @var string * * @ORM\Column(name="view", type="text") * @Assert\Choice(choices = {"work week", "week", "month", "year"}, message = "Choose a valid view.") */ private $view; /** *

POST request on many-to-many association

只愿长相守 提交于 2021-02-16 15:27:07
问题 I have two entities with a many-to-many association: class User extends BaseUser and class Calendar { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="text") */ private $name; /** * @var string * * @ORM\Column(name="view", type="text") * @Assert\Choice(choices = {"work week", "week", "month", "year"}, message = "Choose a valid view.") */ private $view; /** *

Adding services to a Controller through “container.service_subscriber” not working as expected

社会主义新天地 提交于 2021-01-26 02:07:50
问题 I am trying to use the container.service_subscriber tag on my Controller to make some services available without injecting them through the constructor. In our project we don't want to use the autowiring and also can't use the autoconfigure option. The structure of the Controller is as follow: I have a base BaseController which extends from the AbstractFOSRestController of FOSRestBundle which has some common used methods for all my Controllers. That service will be used as parent for my other

FOSRestBundle: The controller must return a response (Array()) given

怎甘沉沦 提交于 2020-02-03 13:24:20
问题 I'm starting with FOSRestBundle. I have added this routing configuration: //Sermovi/Bundle/APIBundle/Resources/config/routing.yml sermovi_api_homepage: type: rest resource: Sermovi\Bundle\APIBundle\Controller\DefaultController //app/config/routing.yml sermovi_api: type: rest prefix: /api resource: "@SermoviAPIBundle/Resources/config/routing.yml" And this config.yml fos_rest: routing_loader: default_format: json view: view_response_listener: true sensio_framework_extra: view: annotations:

FOSRestBundle: The controller must return a response (Array()) given

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-03 13:24:10
问题 I'm starting with FOSRestBundle. I have added this routing configuration: //Sermovi/Bundle/APIBundle/Resources/config/routing.yml sermovi_api_homepage: type: rest resource: Sermovi\Bundle\APIBundle\Controller\DefaultController //app/config/routing.yml sermovi_api: type: rest prefix: /api resource: "@SermoviAPIBundle/Resources/config/routing.yml" And this config.yml fos_rest: routing_loader: default_format: json view: view_response_listener: true sensio_framework_extra: view: annotations:

Symfony Serializer issue - NotNormalizableValueException

元气小坏坏 提交于 2020-02-03 11:38:28
问题 I have an issue when I'm using the serializer with FOSRestBundle in Symfony 4.1 I have the following error message : Could not normalize object of type App\Entity\Youp, no supporting normalizer found. Symfony\Component\Serializer\Exception\NotNormalizableValueException I don't understand why I have this issue, Symfony's Serializer should have an serializer object or I miss something ? See bellow my controller and my entity : <?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; /** *

Symfony Serializer issue - NotNormalizableValueException

半城伤御伤魂 提交于 2020-02-03 11:38:21
问题 I have an issue when I'm using the serializer with FOSRestBundle in Symfony 4.1 I have the following error message : Could not normalize object of type App\Entity\Youp, no supporting normalizer found. Symfony\Component\Serializer\Exception\NotNormalizableValueException I don't understand why I have this issue, Symfony's Serializer should have an serializer object or I miss something ? See bellow my controller and my entity : <?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; /** *

FOSRestBundle: show my custom exception message

烈酒焚心 提交于 2020-01-15 08:16:08
问题 I'm trying to add a custom control of exceptions in FOSRestBundle but it seems to ignore my custom messages (the status code of the response is ok). I have: throw new HttpException(404, "User {$id} not found"); But get this json response: { "error": { "code": 404, "message": "Not Found" } } So I don't find the way to show my custom message 回答1: You could also throw you own exception using the following configuration: fos_rest: exception: codes: 'My\Custom\NotFound\Exception404': 404 messages:

Symfony PUT does not contain all entity properties mapped

a 夏天 提交于 2020-01-14 03:37:06
问题 I am using FOSRestBundle to manage the API in my app. So I got almost everything working, except PUT method, where some of the properties are NULL but they shouldn't since the entity (id 105) has them filled in. Take a look at the putAction: /** * @ParamConverter("user", class="SoftwareBundle:User", options={"mapping": {"user": "guid"}}) */ public function putAction(Request $request, $user) { $form = $this->createForm(new UserType(), $user, ['method' => 'PUT']); $form->handleRequest($request)

FOS rest bundle: unable to find template

自古美人都是妖i 提交于 2020-01-10 18:24:08
问题 I get the exception: Unable to find template "" The other similar questions didn't help; and weirdly enough it was working fine and then suddenly started giving me this exception. composer: "friendsofsymfony/rest-bundle": "0.13.*@dev", "jms/serializer-bundle": "0.12.*@dev", I'm following Automatic route generation: single RESTful controller (for simple resources) config: fos_rest: format_listener: true routing_loader: default_format: json view: view_response_listener: 'force' serializer: