Skip to content

Commit 6baa89f

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: Add attribute configuration block for reusable locator Reorder imports in code examples [Form] Fix an RST reference
2 parents aa13be4 + 756521e commit 6baa89f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

form/events.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ A) The ``FormEvents::PRE_SET_DATA`` Event
6262
The ``FormEvents::PRE_SET_DATA`` event is dispatched at the beginning of the
6363
``Form::setData()`` method. It is used to modify the data given during
6464
pre-population with
65-
:method:`PreSetData::setData() <Symfony\\Component\\Form\\Event\\PreSetDataEvent>`.
6665
The method :method:`Form::setData() <Symfony\\Component\\Form\\Form::setData>`
6766
is locked since the event is dispatched from it and will throw an exception
6867
if called from a listener.
@@ -274,10 +273,10 @@ method of the ``FormFactory``::
274273

275274
// ...
276275

276+
use Symfony\Component\Form\Event\PreSubmitEvent;
277277
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
278278
use Symfony\Component\Form\Extension\Core\Type\EmailType;
279279
use Symfony\Component\Form\Extension\Core\Type\TextType;
280-
use Symfony\Component\Form\Event\PreSubmitEvent;
281280
use Symfony\Component\Form\FormEvents;
282281

283282
$form = $formFactory->createBuilder()
@@ -311,9 +310,9 @@ callback for better readability::
311310
// src/Form/SubscriptionType.php
312311
namespace App\Form;
313312

313+
use Symfony\Component\Form\Event\PreSetDataEvent;
314314
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
315315
use Symfony\Component\Form\Extension\Core\Type\TextType;
316-
use Symfony\Component\Form\Event\PreSetDataEvent;
317316
use Symfony\Component\Form\FormEvents;
318317

319318
// ...
@@ -352,9 +351,9 @@ Consider the following example of a form event subscriber::
352351
namespace App\Form\EventListener;
353352

354353
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
355-
use Symfony\Component\Form\Extension\Core\Type\EmailType;
356354
use Symfony\Component\Form\Event\PreSetDataEvent;
357355
use Symfony\Component\Form\Event\PreSubmitEvent;
356+
use Symfony\Component\Form\Extension\Core\Type\EmailType;
358357
use Symfony\Component\Form\FormEvents;
359358

360359
class AddEmailFieldListener implements EventSubscriberInterface

service_container/service_subscribers_locators.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,23 @@ Now you can inject the service locator in any other services:
554554

555555
.. configuration-block::
556556

557+
.. code-block:: php-attributes
558+
559+
// src/CommandBus.php
560+
namespace App;
561+
562+
use Psr\Container\ContainerInterface;
563+
use Symfony\Component\DependencyInjection\Attribute\Autowire;
564+
565+
class CommandBus
566+
{
567+
public function __construct(
568+
#[Autowire(service: 'app.command_handler_locator')]
569+
private ContainerInterface $locator,
570+
) {
571+
}
572+
}
573+
557574
.. code-block:: yaml
558575
559576
# config/services.yaml

0 commit comments

Comments
 (0)