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

how to fix "keypair size should be SODIUM_CRYPTO_BOX_KEYPAIRBYTES bytes"

 Check that you copied private key, instead of public key. Because their length differs from each other

понедельник, 29 ноября 2021 г.

[JMS serializer] how to set naming strategy

     public function serialize($object, array $serializationGroups)

    {

        $serializer = SerializerBuilder::create();

        $serializer->setPropertyNamingStrategy(new SerializedNameAnnotationStrategy(new IdenticalPropertyNamingStrategy()));

        $serializer->addMetadataDir($this->configDir . "/serializer", 'App\Entity');

        $serializer->setCacheDir($this->cacheDir . "/jms_serializer");

        $serializer = $serializer->build();


        $group = new GroupsExclusionStrategy($serializationGroups);

        $context = SerializationContext::create();

        $context->addExclusionStrategy($group);


        return $serializer->serialize($object, 'json', $context);

    }

It will make JSON string where property field is camelCased instead of Snake_cased. I highly recommend to use 'App\Entity' in addMetadataDir() because by default in Symfony jms_serializer.yaml config is set 'namespace_prefix' in metadata node, and without 'App\Entity' argument YML/XML entity configs won't work. It is also example how to customize Serializer parameters manually with SerializerBuilder without framework config.

вторник, 9 ноября 2021 г.

[Symfony] Cannot read index 'email' from object of type App\Entity\User because it doesn't implement \ArrayAccess

 Its because PropertyAccessor thinks form is an array. To change it, set form data_class. For example in your form Type:

public function configureOptions(OptionsResolver $resolver)

    {

        $resolver

            ->setDefaults([

                'data_class' => User::class,

...


среда, 27 октября 2021 г.

[MacOSX] how to reset permission for Camera and Microphone in Opera

 If you don't have Opera allowed Camera permission in "Security & Privacy" settings window, run this in Terminal:

tccutil reset Camera com.operasoftware.Opera


and restart Opera

понедельник, 25 октября 2021 г.

[behat] chromedriver cannot call send on null fix

 When you have error like this:

Fatal error: Call to a member function waitForLoad() on null (Behat\Testwork\Call\Exception\FatalThrowableError

Add this into your context:

if ($this->getSession()->isStarted() === false) {

            $minkSession->start();

}

четверг, 26 августа 2021 г.

[Symfony] Cannot login at Test environment - fix (in Behat)

When you trying to login in Test env, and it does not show any error (you was returned on login form again), and you does not have anything in logs, except Guard authenticator does not support the request. {"firewall_key":"main","authenticator":"App\\Security\\AppAuthenticator"}, you can try this.

 I removed lines:

 session:

        storage_id: session.storage.mock_file

in config/packages/test/framework.yaml and it worked

вторник, 10 августа 2021 г.

How to create CollectionType with empty one element

 Add 'data' => [''] (not 'empty_data') to the Collection type form configuration.

понедельник, 9 августа 2021 г.

Swedbank Latvia apk download for Huawei users

 Download link here (no viruses, I am also using this version):

https://cloud.mail.ru/public/MzmP/dHKuUHvqc

downloaded via apps.evozi.com.

If you don't have Google Play or using Huawei phones (like P40 lite), you can download Swedbank Latvia android app from here

четверг, 8 июля 2021 г.

[Sylius] GridHelper::renderGrid() must be an instance of Sylius\Component\Grid\View\GridView, instance of Pagerfanta\Pagerfanta - how to fix

 It means you forgot to put `grid: gridname` into your route configuration. For example:

admin_user_index:

    path: /users

    defaults:

        _controller: app.controller.user::indexAction

        _sylius:

            template: "@AdminBundle/grid/index.html.twig"

            grid: admin_user

воскресенье, 4 июля 2021 г.

[Symfony] how to modify data_class object setting logic

 When you need extra manipulations to object data population in form (for example, you need to resolve whether is entered user email is already registered and put existing user object or it needs to create a new user), you might want to set data_class with closure, but there isn't such option.

The right way is to use https://symfony.com/doc/4.4/form/data_mappers.html Data Mappers

воскресенье, 27 июня 2021 г.

how to load BazingaJsTranslationBundle without ajax requests (+ inside Vue components)

  1. Install it as in bundle readme.md
  2. run `php bin/console bazinga:js-translation:dump public/js --format=js`
  3. add in your main template tag: <html lang="{{ app.request.locale|split('_')[0] }}">
  4. add in your js file:
    global.Translator = require('../public/bundles/bazingajstranslation/js/translator.min');
    require('../public/js/translations/messages/ru.js');
  5. if you need also access Translator via Vue, add it in your Vue initialization file:
    Vue.prototype.$t = Translator;
    And use it in your template like this: 
    {{ $t.trans('common.save') }}

вторник, 15 июня 2021 г.

[linux] how to optimize performance with browser hardware acceleration

I had performance issues mostly because browser slowed down everything. I just enabled flags "Override software rendering list" and "GPU rasterization" in chrome://flags and work become much better. I also works on Chrome/Chromium and Opera.

Works well on MSI 2pe leopard 

среда, 12 мая 2021 г.

[Numberformatter] how to show plus sign after decimal number?

 If you need to show number for example "10.000+", where plus is in suffix, write:

$fmt = new NumberFormatter('es_ES', NumberFormatter::DECIMAL);
$fmt->setTextAttribute(NumberFormatter::POSITIVE_SUFFIX, '+');
$result = $fmt->format(10000);

Also if you use `NumberFormatter::POSITIVE_PREFIX` instead of `NumberFormatter::POSITIVE_SUFFIX`, you will get "+10.000".

понедельник, 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)