Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove container aware migrations documentation #244

Merged
merged 1 commit into from Nov 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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