Skip to content

Commit 41e12da

Browse files
varloc2000weaverryan
authored andcommitted
Fix entity manager injection in listener service
Argument 2 of of RegistrationSportListener __construct must be an instance of Doctrine\ORM\EntityManager, but in service configuration "doctrine" was injected.
1 parent 97479d5 commit 41e12da

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cookbook/form/dynamic_form_modification.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,15 +480,15 @@ The subscriber would now look like::
480480
/**
481481
* @var EntityManager
482482
*/
483-
private $om;
483+
private $em;
484484

485485
/**
486486
* @param factory FormFactoryInterface
487487
*/
488-
public function __construct(FormFactoryInterface $factory, EntityManager $om)
488+
public function __construct(FormFactoryInterface $factory, EntityManager $em)
489489
{
490490
$this->factory = $factory;
491-
$this->om = $om;
491+
$this->em = $em;
492492
}
493493

494494
public static function getSubscribedEvents()
@@ -521,7 +521,7 @@ The subscriber would now look like::
521521
{
522522
$data = $event->getData();
523523
$id = $data['event'];
524-
$meetup = $this->om
524+
$meetup = $this->em
525525
->getRepository('AcmeDemoBundle:SportMeetup')
526526
->find($id);
527527

@@ -560,7 +560,7 @@ Now that you have that setup, register your form and the listener as services:
560560
- { name: form.type, alias: acme_meetup_registration }
561561
acme.form.meetup_registration_listener
562562
class: Acme\SportBundle\Form\EventListener\RegistrationSportListener
563-
arguments: [@form.factory, @doctrine]
563+
arguments: [@form.factory, @doctrine.orm.entity_manager]
564564
565565
.. code-block:: xml
566566
@@ -572,7 +572,7 @@ Now that you have that setup, register your form and the listener as services:
572572
</service>
573573
<service id="acme.form.meetup_registration_listener" class="Acme\SportBundle\Form\EventListener\RegistrationSportListener">
574574
<argument type="service" id="form.factory" />
575-
<argument type="service" id="doctrine" />
575+
<argument type="service" id="doctrine.orm.entity_manager" />
576576
</service>
577577
</services>
578578
@@ -590,7 +590,7 @@ Now that you have that setup, register your form and the listener as services:
590590
$container->setDefinition(
591591
'acme.form.meetup_registration_listener',
592592
$definition,
593-
array('form.factory', 'doctrine')
593+
array('form.factory', 'doctrine.orm.entity_manager')
594594
);
595595
596596
In this setup, the ``RegistrationSportListener`` will be a constructor argument

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy