Category : symfony4

I’ve started a new project, creating Entities, Controller, CRUD. I added field to upload images, when I create a new one, everything works fine but I’m struggling with edit and delete. /** * @ORMColumn(type="string", length=255) * @AssertFile(mimeTypes={ "image/png", "image/jpeg" }) */ private $image; /** * @Route("/{id}/edit", name="post_edit", methods={"GET","POST"}) */ public function edit(Request $request, Post $post): ..

Read more

I have a generic service who uses a configuration to do its processing. <?php namespace AppService; class MyCustomService { /** * @var array */ private $config; /** * MyCustomService constructor. * * @param array $config */ public function __construct(array $config) { $this->config = $config; } public function getConfig() { return $this->config; } } I want ..

Read more

I have created a voter to manage impersonation in my project. However, I need to check some properties on my impersonated User to see if the impersonator can actually impersonate this user. Here is my voter: namespace AppSecurityVoter; use SymfonyComponentHttpFoundationRequestStack; use SymfonyComponentSecurityCoreAuthenticationTokenTokenInterface; use SymfonyComponentSecurityCoreAuthorizationVoterVoter; use SymfonyComponentSecurityCoreSecurity; use SymfonyComponentSecurityCoreUserUserInterface; class SwitchUserVoter extends Voter { private $security; ..

Read more

I’m trying to make a function to download pdf files based on pdf id stored in the database. Files are stored in public/CVs folder and I’m getting the following error Attempted to call an undefined method named "getParameter" of class "SymfonyComponentDependencyInjectionArgumentServiceLocator". Here is the code: /** * @Route("/home/download/{id}") */ public function download($id) { try { ..

Read more

Hello symfony family I am a beginner in symfony I have a question about the good practice Eg: I have two entities Author and article the condition is: the author cannot add more than one article per day. where I can add my specific data validation processing. is it in the controlor or in validator ..

Read more