symfony-3.4

How to set the locale with symfony 3.4

久未见 提交于 2019-12-24 00:36:20
问题 How can I change the locale using symfony 3.4 (php)? I have the locale saved for each user in my database. Now on this page they explain that you should create an event listener to set the locale. But they only provide a method - in which class do I put this method and how do I wire it up using my services.yml? And if I'm in the service - how can I access my user object to actually get the locale I want to set? 回答1: Here is an example provided by the docs on how to create an kernel request

symfony 3.4 “Refreshing a deauthenticated user is deprecated”

青春壹個敷衍的年華 提交于 2019-12-23 19:40:01
问题 while trying to upgrade existing symfony project from 3.3.10 to 3.4.x which should be LTS, I managed to upgrade components through composer. after upgrade all things works as expected, but unit tests shows deprecation error Refreshing a deauthenticated user is deprecated as of 3.4 and will trigger a logout in 4.0: 77x some googling around points me to the commits probably showing the change https://github.com/showpad/Symfony-Security/pull/1/commits/3663bbec5fc60565de476fc180f85e1121339072 so

Symfony 2.8 -> 3.4 Upgrade IsGranted('IS_AUTHENTICATED_ANONYMOUSLY') Throws Errors

谁说我不能喝 提交于 2019-12-20 02:23:25
问题 I'm in the process of upgrading Symfony from 2.8 to 3.4 and I have a Authentication Listener. The constructor of the listener public function __construct(EntityManager $entityManager, SessionInterface $session, Security $security, LoggerInterface $logger, Redis $redis, $secret) { $this->entityManager = $entityManager; $this->session = $session; $this->security = $security; $this->logger = $logger; $this->redis = $redis; $this->secret = $secret; } On Request Function which is calling in

Symfony 3.4 logger service

痞子三分冷 提交于 2019-12-18 04:08:06
问题 When I called logger service get this information message in log file it's worked but write this message in the log file: php.INFO: User Deprecated: The "logger" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"logger\" service is private, getting it

Symfony 3.4 logger service

こ雲淡風輕ζ 提交于 2019-12-18 04:07:42
问题 When I called logger service get this information message in log file it's worked but write this message in the log file: php.INFO: User Deprecated: The "logger" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. {"exception":"[object] (ErrorException(code: 0): User Deprecated: The \"logger\" service is private, getting it

Adapting a class Using php's __call method: Passing the parameters

不问归期 提交于 2019-12-13 03:32:15
问题 Based upon answer on my Symfony 3.4 project I thought of using the magic __call method in order to have a common way to invoke repositories as a service: namespace AppBundle\Services; use Doctrine\ORM\EntityManagerInterface; class RepositoryServiceAdapter { private $repository=null; /** * @param EntityManagerInterface the Doctrine entity Manager * @param String $entityName The name of the entity that we will retrieve the repository */ public function __construct(EntityManagerInterface

How to install api-platform in existing symfony 3.4 application without flex?

馋奶兔 提交于 2019-12-11 18:35:11
问题 I try to install api-platform on an existing Symfony 3.4 application, which is installed without flex. When I try to install it with composer require api-platform/core , an error occured: Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages. Problem 1 - Conclusion: don't install api-platform/core v2.4.3 - Conclusion: don't install api-platform/core v2.4.2 - Conclusion: don

symfony 3.4 Type error: Argument 1 passed to … must be an instance of DateTime, null given,

前提是你 提交于 2019-12-11 18:17:22
问题 In the entity the date time is decalared: /** * @var \DateTime * @ORM\Column(name="task_date_start", type="datetime", nullable=true) */ private $taskDateStart; in the form $builder->add('taskDateStart', DateType::class, [ "widget" => "single_text", "html5" => false, "format" => "dd-MM-yyyy" , "attr" => ["class" => "js-datepicker"], "required" => false ]); i've this error when inserting null in to the field Argument 1 passed to ... must be an instance of DateTime, null given 回答1: The problem

Autowire doesn't seems to be working

走远了吗. 提交于 2019-12-11 17:51:50
问题 [PROBLEM] I'm on Symfony 3.4, and I got some issues with the way services are handled now. Even though it's working, I'm forced to use the old way, which is a problem. I'm using DataTransformer on a form, but for some reasons, I got the following error Type error: Argument 1 passed to AppBundle\Form\VarianteEscalierOptGc\VarianteEscalierOptGcEditPoteauType::__construct() must be an instance of AppBundle\Form\DataTransformer\VarianteEscalierTransformer, none given As written in the doc: That's

Symfony The annotation does not exist, or could not be auto-loaded - Symfony Validation with Doctrine

回眸只為那壹抹淺笑 提交于 2019-12-11 17:31:09
问题 We have a legacy app which is not based on symfony. Doctrine is in use and now we would like to add validation to the models. Seems that the Annotations never get autoloaded, even when "use" statements are in use. [Semantical Error] The annotation "@Symfony\Component\Validator\Constraints\NotBlank" in property Test\Stackoverflow\User::$Username does not exist, or could not be auto-loaded. Wrote a small demo application to showcase the problem and how we create the entity manager and