понедельник, 19 апреля 2021 г.

[JMSSerializer] default serialization group are ignored fix

 If your default serialization group not working (does not ignore fields which should be shown only with specific group, not Default), check that \JMS\Serializer\Exclusion\GroupsExclusionStrategy is added into \JMS\Serializer\Context at  \JMS\Serializer\GraphNavigator::accept() method.

If you are using Sylius (or standalone bundles), it occurs when \FOS\RestBundle\Serializer\JMSSerializerAdapter does not add GroupsExclusionStrategy. You can fix it with adding serialization_groups: [Default] like this:

api_building_show:

    path: /exam/{id}

    methods: [GET]

    defaults:

        _controller: app.controller.building:showAction

        _sylius:

            serialization_groups: [Default]

суббота, 17 апреля 2021 г.

[FOSRestBundle] Showing custom Exception message no working fix

 If ./config/packages/fos_rest.yaml:

fos_rest:

    exception:

        messages:

            Symfony\Component\HttpKernel\Exception\HttpException: true

for you too, you can inject this service manually like this in services.yaml:

fos_rest.exception.messages_map:

        class: FOS\RestBundle\Util\ExceptionValueMap

        public: false

        arguments:

            - { Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException: true }

thanks to https://github.com/FriendsOfSymfony/FOSRestBundle/issues/1522 

четверг, 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)

понедельник, 23 ноября 2020 г.

[Sylius] Argument 1 passed to Sylius\Component\Grid\Definition\Filter::setTemplate() must be of the type string, null given fix

 put `grid: <gridname>` into your route like this:

tests:
path: /tests
defaults:
_controller: app.controller.test:indexAction
_sylius:
template: tests/index.html.twig
grid: app_test

воскресенье, 22 ноября 2020 г.

[Monofony] how to create/get admin user?

 run `php bin/console app:install:database`, after then you will have user "admin@example.com" with password "admin". You can use it in 127.0.0.1:8000/admin/login

понедельник, 9 ноября 2020 г.

[Vue] [vee-validate] collection.indexOf is not a function - how to fix

 It occurs when to get error message (with `errors.first('myfield')`) of not existing field. In another words, check that component field has v-validate tag attribute (and maybe also `name` attribute). Or remove `errors.first('myfield')` line at all, this will fix this error.