Best practice is to use a service to preserve your essence. This container will enter the container and set it when the updateMyEntity() method is updateMyEntity() .
Inside your controller (or what you want):
 $user = new User('foo'); $user->setSomeProperty('bar'); $userService->update($user); 
Inside UserService :
 public function update(User $user) { $user->setSomeParameter($this->container->getParameter('value')); $this->em->persist($user); } 
 source share