Skip to content

Commit

Permalink
Restoring dialog helper (required for migrations as of doctrine#78 ) …
Browse files Browse the repository at this point in the history
…with tests
  • Loading branch information
Ocramius committed Jul 13, 2012
1 parent 9eacd28 commit 4a83759
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 12 deletions.
44 changes: 44 additions & 0 deletions .travis/Version20120714005702.php
@@ -0,0 +1,44 @@
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace TravisDoctrineMigrations;

use Doctrine\DBAL\Migrations\AbstractMigration,
Doctrine\DBAL\Schema\Schema;

/**
* Empty test migration used for testing
*/
class Version20120714005702 extends AbstractMigration
{
/**
* {@inheritDoc}
*/
public function up(Schema $schema)
{
$this->addSql("SELECT 'Migration succeeded!'");
}

/**
* {@inheritDoc}
*/
public function down(Schema $schema)
{
}
}
11 changes: 11 additions & 0 deletions .travis/migrations-execute-config.xml
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-migrations
xmlns="http://doctrine-project.org/schemas/migrations/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/migrations/configuration http://doctrine-project.org/schemas/migrations/configuration.xsd"
>
<name>doctrine-migrations configuration for travis tests (running preset migrations)</name>
<migrations-namespace>TravisDoctrineMigrations</migrations-namespace>
<table name="doctrine_migration_versions"/>
<migrations-directory>vendor/doctrine/doctrine-orm-module/.travis</migrations-directory>
</doctrine-migrations>
3 changes: 2 additions & 1 deletion .travis/run-cli.sh
Expand Up @@ -13,4 +13,5 @@
./vendor/bin/doctrine-module orm:run-dql "SELECT COUNT(a) FROM DoctrineORMModuleTest\Assets\Entity\Test a"
./vendor/bin/doctrine-module orm:schema-tool:drop
./vendor/bin/doctrine-module migrations:generate --configuration=vendor/doctrine/doctrine-orm-module/.travis/migrations-config.xml
./vendor/bin/doctrine-module migrations:diff --configuration=vendor/doctrine/doctrine-orm-module/.travis/migrations-config.xml
./vendor/bin/doctrine-module migrations:diff --configuration=vendor/doctrine/doctrine-orm-module/.travis/migrations-config.xml
./vendor/bin/doctrine-module migrations:execute 20120714005702 -n --configuration=vendor/doctrine/doctrine-orm-module/.travis/migrations-execute-config.xml
23 changes: 12 additions & 11 deletions src/DoctrineORMModule/Module.php
Expand Up @@ -13,14 +13,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace DoctrineORMModule;

use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ORM\Tools\Console\ConsoleRunner as ORMConsoleRunner;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use DoctrineModule\Service as CommonService;
use DoctrineORMModule\Service as ORMService;

Expand All @@ -31,6 +31,9 @@
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\EventManager\EventInterface;

use Symfony\Component\Console\Helper\DialogHelper;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand;
use Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand;
Expand All @@ -43,10 +46,8 @@
/**
* Base module for Doctrine ORM.
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @license MIT
* @link www.doctrine-project.org
* @since 1.0
* @version $Revision$
* @author Kyle Spraggs <theman@spiffyjr.me>
* @author Marco Pivetta <ocramius@gmail.com>
*/
Expand All @@ -57,7 +58,7 @@ class Module implements ServiceProviderInterface, ConfigProviderInterface
*/
public function init(ModuleManagerInterface $moduleManager)
{
AnnotationRegistry::registerLoader(function ($className) {
AnnotationRegistry::registerLoader(function($className) {
return class_exists($className);
});
}
Expand All @@ -76,7 +77,7 @@ public function onBootstrap(EventInterface $e)
/* @var $cli \Symfony\Component\Console\Application */
$cli = $e->getTarget();

ORMConsoleRunner::addCommands($cli);
ConsoleRunner::addCommands($cli);
$cli->addCommands(array(
new DiffCommand(),
new ExecuteCommand(),
Expand All @@ -90,10 +91,10 @@ public function onBootstrap(EventInterface $e)
$sm = $e->getParam('ServiceManager');
/* @var $em \Doctrine\ORM\EntityManager */
$em = $sm->get('doctrine.entitymanager.orm_default');
$db = new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection());
$eh = new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em);
$cli->getHelperSet()->set($db, 'db');
$cli->getHelperSet()->set($eh, 'em');
$helperSet = $cli->getHelperSet();
$helperSet->set(new DialogHelper(), 'dialog');
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
$helperSet->set(new EntityManagerHelper($em), 'em');
});
}

Expand Down

0 comments on commit 4a83759

Please sign in to comment.