8000 Fix PHP code for registering service · symfony/symfony-docs@9e28901 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9e28901

Browse files
committed
Fix PHP code for registering service
1 parent 9960f9c commit 9e28901

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

cookbook/form/dynamic_form_modification.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,13 +408,15 @@ it with :ref:`dic-tags-form-type`.
408408
.. code-block:: php
409409
410410
// app/config/config.php
411-
$definition = new Definition('AppBundle\Form\Type\FriendMessageFormType');
412-
$definition->addTag('form.type', array('alias' => 'app_friend_message'));
413-
$container->setDefinition(
414-
'app.form.friend_message',
415-
$definition,
416-
array('security.context')
411+
use Symfony\Component\DependencyInjection\Reference;
412+
413+
$definition = new Definition(
414+
'AppBundle\Form\Type\FriendMessageFormType',
415+
array(new Reference('security.context'))
417416
);
417+
$definition->addTag('form.type', array('alias' => 'app_friend_message'));
418+
419+
$container->setDefinition('app.form.friend_message', $definition);
418420
419421
If you wish to create it from within a service that has access to the form factory,
420422
you then use::

0 commit comments

Comments
 (0)
0