Skip to content

Commit

Permalink
Merge pull request #244 from j4nr6n/patch-1
Browse files Browse the repository at this point in the history
Remove container aware migrations documentation
  • Loading branch information
alcaeus committed Nov 25, 2018
2 parents c7373c2 + a6ce2c2 commit 909088f
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions Resources/doc/index.rst
Expand Up @@ -329,67 +329,6 @@ If you don't want to use this workflow and instead create your schema via
Otherwise Doctrine will try to run all migrations, which probably will not work.
Container Aware Migrations
--------------------------
In some cases you might need access to the container to ensure the proper update of
your data structure. This could be necessary to update relations with some specific
logic or to create new entities.
Therefore you can just implement the ContainerAwareInterface with its needed methods
to get full access to the container or ContainerAwareTrait if you use Symfony >= 2.4.
.. code-block:: php
// ...
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Version20130326212938 extends AbstractMigration implements ContainerAwareInterface
{
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
public function up(Schema $schema)
{
// ... migration content
}
public function postUp(Schema $schema)
{
$converter = $this->container->get('my_service.convert_data_to');
// ... convert the data from markdown to html for instance
}
}
With the trait
.. code-block:: php
// ...
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
class Version20130326212938 extends AbstractMigration implements ContainerAwareInterface
{
use ContainerAwareTrait;
public function up(Schema $schema)
{
// ... migration content
}
public function postUp(Schema $schema)
{
$converter = $this->container->get('my_service.convert_data_to');
// ... convert the data from markdown to html for instance
}
}
Manual Tables
-------------
Expand Down

0 comments on commit 909088f

Please sign in to comment.