File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -277,9 +277,10 @@ In some cases you may need to access some services to load the fixtures.
277
277
Symfony2 makes it really easy: the container will be injected in all fixture
278
278
classes implementing :class: `Symfony\\ Component\\ DependencyInjection\\ ContainerAwareInterface `.
279
279
280
- Let's rewrite the first firxtures to encode the password sotred in the database.
281
- This will use the encoder factory to encode the password, ensuring it is
282
- encoded in the way used by the security component when checking it:
280
+ Let's rewrite the first fixture to encode the password before it's stored
281
+ in the database (a very good practice). This will use the encoder factory
282
+ to encode the password, ensuring it is encoded in the way used by the security
283
+ component when checking it:
283
284
284
285
.. code-block :: php
285
286
@@ -314,5 +315,10 @@ encoded in the way used by the security component when checking it:
314
315
}
315
316
}
316
317
318
+ As you can see, all you need to do is add ``ContainerAwareInterface `` to
319
+ the class and then create a new ``setContainer() `` method that implements
320
+ that interface. Before the fixture is executed, Symfony will call the ``setContainer() ``
321
+ method automatically. As long as you store the container as a property on
322
+ the class (as shown above), you can access it in the ``load() `` method.
317
323
318
324
.. _`Doctrine Data Fixtures` : https://github.com/doctrine/data-fixtures
You can’t perform that action at this time.
0 commit comments