symfony-4.2

Use the “circular_reference_handler” key of the context instead symfony 4.2

时光怂恿深爱的人放手 提交于 2020-01-02 15:05:14
问题 I have to serialize an object and I get the ever so common "circular reference error" I have used the old Symfony method : $normalizer = new ObjectNormalizer(); // Add Circular reference handler $normalizer->setCircularReferenceHandler(function ($object) { return $object->getId(); }); $normalizers = array($normalizer); $encoders = [new JsonEncoder()]; $serializer = new Serializer($normalizers, $encoders); This work but as of Symfony 4.2 I get the exception you see in the title of this

Symfony 4 EasyAdmin how to encrypt passwords?

混江龙づ霸主 提交于 2019-12-20 01:46:32
问题 I am using EasyAdmin to add/edit users and wanted to ask if there is a possibility of encrypting your passwords? Password encryption worked previously when I used the Symfony 4 make:registration-form but I can't use that now, I have to use EasyAdmin. easy_admin.yaml easy_admin: entities: User: class: App\Entity\User password_encoding: { algorithm: 'bcrypt', cost: 12 } (Actual) I go to EasyAdmin page (/admin), click User, Add User, fill in email (test@gmail.com) and password (test), click Save

Filter required in Api Platform

无人久伴 提交于 2019-12-13 03:40:58
问题 Im using API Platform and I have defined a custom filter following https://api-platform.com/docs/core/filters/#creating-custom-filters It works ok, but I need to that filter is required everytime that application do a GET HTTP Request of particular entity (where the filter is set). I have check this code: // This function is only used to hook in documentation generators (supported by Swagger and Hydra) public function getDescription(string $resourceClass): array { if (!$this->properties) {

Getting error while using interval in doctrine

痴心易碎 提交于 2019-12-12 18:56:29
问题 When I use below query (Doctrine 2), I was getting error, and can't use INTERVAL in query, $qb->andWhere("(pv.appointment_date + INTERVAL 48 HOUR) >= UTC_TIMESTAMP()"); Error: Expected Doctrine\ORM\Query\Lexer::T_CLOSE_PARENTHESIS, got '48'" 回答1: If you want to use INTERVAL (in Doctrine 2, DQL) on mysql comumn field, You can use as below, $qb->andWhere("DATE_ADD(pv.appointmentDate,48,'hour') >= UTC_TIMESTAMP()"); It will print SQL as below, ...... DATE_ADD(p0_.appointmentDate, INTERVAL 48

How to use JMSSerializer with symfony 4.2

耗尽温柔 提交于 2019-12-11 17:21:28
问题 i am building an Api with symfony 4.2 and want to use jms-serializer to serialize my data in Json format, after installing it with composer require jms/serializer-bundle and when i try to use it this way : ``` demands = $demandRepo->findAll(); return $this->container->get('serializer')->serialize($demands,'json');``` it gives me this errur : Service "serializer" not found, the container inside "App\Controller\DemandController" is a smaller service locator that only knows about the "doctrine",

Symfony 4 argument has no type-hint, you should configure its value explicitly

百般思念 提交于 2019-12-11 02:27:39
问题 Symfony 4.2.3 Recently upgraded from version 3.4 to 4.2.3 and got my project working, but when setting autoconfigure in services.yaml to true, I will receive this error message: Cannot autowire service "App\EventListener\RedirectToLocaleActiveListener": argument "$localeActive" of method "__construct()" has no type-hint, you should configure its value explicitly. My services.yaml parameters: locale: de locale_active: de app_locales: de|en uploads_directory_name: uploads uploads_profile

Use the “circular_reference_handler” key of the context instead symfony 4.2

北战南征 提交于 2019-12-06 05:02:28
I have to serialize an object and I get the ever so common "circular reference error" I have used the old Symfony method : $normalizer = new ObjectNormalizer(); // Add Circular reference handler $normalizer->setCircularReferenceHandler(function ($object) { return $object->getId(); }); $normalizers = array($normalizer); $encoders = [new JsonEncoder()]; $serializer = new Serializer($normalizers, $encoders); This work but as of Symfony 4.2 I get the exception you see in the title of this question : use the "circular_reference_handler" key of the context instead Symfony 4.2 I cannot find any