8000 [cookbook][doctrine] Tweaking and adding a few more details · chtitux/symfony-docs@d6e39c4 · GitHub
[go: up one dir, main page]

Skip to content

Commit d6e39c4

Browse files
committed
[cookbook][doctrine] Tweaking and adding a few more details
1 parent 9427755 commit d6e39c4

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cookbook/doctrine/doctrine_fixtures.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,10 @@ In some cases you may need to access some services to load the fixtures.
277277
Symfony2 makes it really easy: the container will be injected in all fixture
278278
classes implementing :class:`Symfony\\Component\\DependencyInjection\\ContainerAwareInterface`.
279279

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:
283284

284285
.. code-block:: php
285286
@@ -314,5 +315,10 @@ encoded in the way used by the security component when checking it:
314315
}
315316
}
316317
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.
317323

318324
.. _`Doctrine Data Fixtures`: https://github.com/doctrine/data-fixtures

0 commit comments

Comments
 (0)
0