I’m struggling with a ‘strange’ behavior. When I use setMaxResult() + Rand() on my query_builder. I got randomly the message that my value is not valid. SymfonyComponentValidatorConstraintViolation {#1320 ▼ -message: “Cette valeur n’est pas valide.” -messageTemplate: “This value is not valid.” -parameters: [▶] -plural: null -root: SymfonyComponentFormForm {#911 ▶} -propertyPath: “children[press]” -invalidValue: “8” -constraint: SymfonyComponentFormExtensionValidatorConstraintsForm {#987 …} -code: “1dafa156-89e1-4736-b832-419c2e501fca” -cause:
Tag: symfony5
How to assert if a phpunit test writes a certain log entry / how to assert if emails are sent
I have a service class in my symfony5 project on php8, which is sending emails following certain rules. With my test want to check if the correct mails are sent. This task exists for several projects, so I really want to find a solution for this. The method, which collects the receiver of the mails is currently private and you
New alternative for getDoctrine() in Symfony 5.4 and up
As my IDE points out, the AbstractController::getDoctrine() method is now deprecated. I haven’t found any reference for this deprecation neither in the official documentation nor in the Github changelog. What is the new alternative or workaround for this shortcut? Answer As mentioned here: Instead of using those shortcuts, inject the related services in the constructor or the controller methods. You
Customize new authentication errors messages on Symfony5.3
on my new symfony 5.3 project i just implemented the new authentication system, and it works fine, but my problem is that i can’t customize the authentication errors: in the method: onAuthentificationFailure in the AbstractLoginFormAuthenticator but in my view it only displays the session error which is normal since my controller calls the getLastAuthenticationError() method. but how could I display
Check JWT (Firebase) Token with Symfony 5.3
I’m working on an API, and I had implemented a JWT to make it stateless. I created an AuthController, which returns a JWT when login information is correct. Here you can see the return code that generates the token: This is the result when I run the authenticate method, un the URL localhost:8000/authenticate. Now, what I would need to do
Symfony 5.2.11: Problem with creating Custom Access Decision Manager
I am trying to create a Custom Access Decision Manager by implementing AccessDecisionManagerInterface on Symfony 5.2. Symfony recognizes the decision manager and instantiate it, but it doesn’t pass Voters array to decision manager. So it can’t collect votes, however the default decision manager works fine. I have followed the information provided on Symfony website. I have also copied the decision
shopware6 – inject data in profile page or route http://domain/account/*
In Shopware6, I want to write a controller for the route http://domain/account/*. Only I have to write in eventListener or is there other possibility? I also could not find events for this url (http://domain/account/address). This is my current way, but this is not enough. File : {moduleOneSubscriber.php} Answer There does not seem to be a generic event only for all
Symfony 5 / Doctrine: Sorting entity collection by creation DateTime
I am developing a project using Symfony 5. One of my use-cases involves reading a collection from the Database, with the items sorted by creation order, descending (newest first). I am using the “Timestampable” extension from “stof/doctrine-extensions-bundle” to save the createdAt and updatedAt timestamps in my entity. According to Doctrine documentation, I can sort items ussing the Repository methods: This
How to set option for validation constraint in Symfony globally?
I need to change format for DateTime validation constraint but I want to do it globally for the whole application to not copy-paste it like this: (I use yaml config in my application) Is there any option to do it globally in Symfony 5 application, using DI parameters or some other way? I didn’t find anything about it in official
Symfony autowire/autoconfigure not working
I created a symfony 5.3 api. My plan is to inject the “EntityManager” via “EntityManagerInterface”. Error that comes: My services.yaml My CreateUserAccountController.php in src/Controller/: My composer.json: I know that I dont use the Manager, but it doesn´t work for me. The webserver I use: symfony cli webserver Has anyone a idea, where the problem is? Answer This is actually a