forked from doctrine/DoctrineMigrationsBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a DI extension for DoctrineMigrations, removed --bundle option …
…in favor of application level settings
- Loading branch information
Showing
9 changed files
with
111 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Symfony\Bundle\DoctrineMigrationsBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\Definition\Builder\NodeBuilder; | ||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
|
||
/** | ||
* DoctrineMigrationsExtension configuration structure. | ||
* | ||
* @author Lukas Kahwe Smith <smith@pooteeweet.org> | ||
*/ | ||
class Configuration | ||
{ | ||
/** | ||
* Generates the configuration tree. | ||
* | ||
* @return \Symfony\Component\Config\Definition\NodeInterface | ||
*/ | ||
public function getConfigTree() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('doctrine_migrations', 'array'); | ||
|
||
$rootNode | ||
->scalarNode('dir_name')->defaultValue('%kernel.root_dir%/DoctrineMigrations')->cannotBeEmpty()->end() | ||
->scalarNode('namespace')->defaultValue('Application\Migrations')->cannotBeEmpty()->end() | ||
->scalarNode('table_name')->defaultValue('migration_versions')->cannotBeEmpty()->end() | ||
->scalarNode('name')->defaultValue('Application Migrations')->end(); | ||
|
||
return $treeBuilder->buildTree(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\DoctrineMigrationsBundle\DependencyInjection; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\Config\Definition\Processor; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
/** | ||
* DoctrineMigrationsExtension. | ||
* | ||
* @author Lukas Kahwe Smith <smith@pooteeweet.org> | ||
*/ | ||
class DoctrineMigrationsExtension extends Extension | ||
{ | ||
/** | ||
* Responds to the twig configuration parameter. | ||
* | ||
* @param array $configs | ||
* @param ContainerBuilder $container | ||
*/ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$processor = new Processor(); | ||
$configuration = new Configuration(); | ||
|
||
$config = $processor->process($configuration->getConfigTree(), $configs); | ||
|
||
foreach ($config as $key => $value) { | ||
$container->setParameter($this->getAlias().'.'.$key, $value); | ||
} | ||
} | ||
|
||
/** | ||
* Returns the base path for the XSD files. | ||
* | ||
* @return string The XSD base path | ||
*/ | ||
public function getXsdValidationBasePath() | ||
{ | ||
return __DIR__.'/../Resources/config/schema'; | ||
} | ||
|
||
public function getNamespace() | ||
{ | ||
return 'http://www.symfony-project.org/schema/dic/doctrine/migrations'; | ||
} | ||
} |