Показаны сообщения с ярлыком sylius-resource-bundle. Показать все сообщения
Показаны сообщения с ярлыком sylius-resource-bundle. Показать все сообщения

суббота, 12 февраля 2022 г.

[SyliusResourceBundle] how to pass model into controller?

 Sometimes you don't need to use model instead of entity, and then save some data into entity and persist it. It means you cannot use it in Sylius ResourceControllers, because your model must implement ResourceInterface, create dedicated ResourceController, Repository, Manager, and model cannot do it.

If you want it, this means you doing it wrong, because it violated CRUD principles. The best solution is to use Symfony Data Transformers https://symfony.com/doc/current/form/data_transformers.html , add it to your form, implement transform() method, where it will create your model/DTO object from entity, and reverseTransform(), where DTO will be converted into Entity object.

четверг, 15 апреля 2021 г.

[FosRestBundle] [JmsSerializerBundle] how to show datetime in correct timezone

If your date fields looks like "2021-04-08T00:00:00+00:00", instead of your preferred timezone, set correct timezone in your cli/fpm php.ini:

[Date]

date.timezone = "Europe/Riga"

вторник, 16 февраля 2021 г.

[JMS Serializer] does not show field data in response - how to fix

 When you try to get data in json response, check that field is not empty (null)