symfony

POST request on many-to-many association

只愿长相守 提交于 2021-02-16 15:27:07
问题 I have two entities with a many-to-many association: class User extends BaseUser and class Calendar { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="text") */ private $name; /** * @var string * * @ORM\Column(name="view", type="text") * @Assert\Choice(choices = {"work week", "week", "month", "year"}, message = "Choose a valid view.") */ private $view; /** *

How to translate emails when sending them asynchronously with Symfony Messenger?

我是研究僧i 提交于 2021-02-16 14:11:54
问题 I configured the Symfony mailer to send emails with messenger. https://symfony.com/doc/current/mailer.html#sending-messages-async I have my emails in two languages and I rely on the requests to detect the language, but now the emails are not translated. How can I get the messages to be translated in the language detected in the request? In my controller: $mailer->send( $user->email, $this->translator->trans('mails.recover.subject'), 'email/client/password-recovery.html.twig', compact('user',

Symfony2 Form Entity Update

空扰寡人 提交于 2021-02-16 04:16:32
问题 Can anyone please show me a specific example of a Symfony2 form entity update? The book only shows how to create a new entity. I need an example of how to update an existing entity where I initially pass the id of the entity on the query string. I'm having trouble understanding how to access the form again in the code that checks for a post without re-creating the form. And if I do recreate the form, it means I have to also query for the entity again, which doesn't seem to make much sense.

Symfony2 Form Entity Update

回眸只為那壹抹淺笑 提交于 2021-02-16 04:14:33
问题 Can anyone please show me a specific example of a Symfony2 form entity update? The book only shows how to create a new entity. I need an example of how to update an existing entity where I initially pass the id of the entity on the query string. I'm having trouble understanding how to access the form again in the code that checks for a post without re-creating the form. And if I do recreate the form, it means I have to also query for the entity again, which doesn't seem to make much sense.

Symfony: ManyToMany table extra columns

亡梦爱人 提交于 2021-02-15 06:49:50
问题 I have a many to many table for User and House , called user_house . Instead of just two columns: user_id and house_id, i want to add 3 more: eg action, created_at, updated_at. How can I do this? I cannot find any relevant docs on this. The following just creates a separate table with two columns in it. class User extends EntityBase { ... /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\House") */ protected $action; Basically, what I want to achieve is: in the user_house table the

Dependency injection with custom Doctrine 2 data type

本小妞迷上赌 提交于 2021-02-15 06:19:19
问题 I have pretty much an identical issue as Dependency injection with custom Doctrine 2 hydrator, but I need to inject a service into a custom data type , not into a hydrator. The solution in the referenced question is relies on duplicating and modifying doctrine source code as Doctrine initializes the classes itself. Hopefully another approach is viable to custom data types? This is for a Symfony3 application, if there could be some magic to be applied there. 回答1: Per the comments in the

Dependency injection with custom Doctrine 2 data type

試著忘記壹切 提交于 2021-02-15 06:15:56
问题 I have pretty much an identical issue as Dependency injection with custom Doctrine 2 hydrator, but I need to inject a service into a custom data type , not into a hydrator. The solution in the referenced question is relies on duplicating and modifying doctrine source code as Doctrine initializes the classes itself. Hopefully another approach is viable to custom data types? This is for a Symfony3 application, if there could be some magic to be applied there. 回答1: Per the comments in the

Dependency injection with custom Doctrine 2 data type

六眼飞鱼酱① 提交于 2021-02-15 06:15:54
问题 I have pretty much an identical issue as Dependency injection with custom Doctrine 2 hydrator, but I need to inject a service into a custom data type , not into a hydrator. The solution in the referenced question is relies on duplicating and modifying doctrine source code as Doctrine initializes the classes itself. Hopefully another approach is viable to custom data types? This is for a Symfony3 application, if there could be some magic to be applied there. 回答1: Per the comments in the

Symfony 4.3 disable translation fallback

岁酱吖の 提交于 2021-02-11 15:53:37
问题 Following the 4.3 documentation about translations (https://symfony.com/doc/4.3/translation.html#basic-translation), I'm trying to translate a page title. I don't want to fallback to anything if the translation doesn't exist for the current locale. Right now, I'm getting the default locale translation if it exists or the first translation it can find. How can I disable that? Here's my /config/packages/translation.yaml file: framework: default_locale: de translator: default_path: '%kernel

One-To-One between Fos-user-bundle and custom entity - no mapping found

南笙酒味 提交于 2021-02-11 13:50:07
问题 I wanted to create a database relationship between fosuserbundle and my Leed entity. I created the entire relationship by make: entity and easily created relationships in the database. I can download both the user entity, the leed and the user entity leed. The problem is currently in two cases. Both when I want to download all leeds simply or if I want to download leeds by the user. SIMPLE GET ALL LEDS: $leed = $this->getDoctrine() ->getRepository(Leed::class) ->find(1); GET ERROR: No mapping