Merge pull request #358 from romainneutron/developer-console

[3.8] Developer console
This commit is contained in:
Romain Neutron
2013-05-28 11:15:50 -07:00
4 changed files with 77 additions and 2 deletions

View File

@@ -24,6 +24,7 @@
- Add `Link` header in permalink resources HTTP responses.
- Global speed improvement on report.
- Upload now monitors number of files transmitted.
- Add bin/developer console for developement purpose.
* 3.7.12 (2013-05-13)

View File

@@ -9,9 +9,12 @@
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\CLI;
use Alchemy\Phrasea\Core\Version;
use Alchemy\Phrasea\Command\Developer\RegenerateSqliteDb;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Alchemy\Phrasea\CLI;
// DBAL Commands
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Doctrine\DBAL\Tools\Console\Command\ImportCommand;
@@ -34,7 +37,17 @@ use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand;
require_once __DIR__ . '/../vendor/autoload.php';
try {
$cli = new CLI("Phraseanet Doctrine Console");
$cli = new CLI("
___ ___ _ _ ___ __ __ ___ ___ ___ ____ __ __ __ ___
( \( _)( )( )( _)( ) / \( ,\( _)( ,) (_ _)/ \ / \( ) / __)
) ) )) _) \\// ) _) )(__( () )) _/ ) _) ) \ )( ( () )( () ))(__ \__ \
(___/(___) (__) (___)(____)\__/(_) (___)(_)\_) (__) \__/ \__/(____)(___/
Phraseanet Copyright (C) 2004 Alchemy
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type `about:license' for details.\n\n"
. ' Phraseanet Developer Tools ', Version::getName() . ' ' . Version::getNumber());
$helpers = array(
'db' => new ConnectionHelper($cli['EM']->getConnection()),
@@ -46,6 +59,8 @@ try {
$helperSet->set($helper, $name);
}
$cli->command(new RegenerateSqliteDb());
$cli['console']->addCommands(array(
// DBAL Commands
new RunSqlCommand(),

View File

@@ -25,6 +25,11 @@ $finder
->name('.gitmodules')
->name('.gitignore')
->name('check_cs.php')
->name('bin/behat')
->name('bin/developer')
->name('bin/doctrine.php')
->name('bin/doctrine')
->name('bin/phpunit')
->name('cleaner.php')
->name('build-env.sh')
->name('phpunit.xml.dist')

View File

@@ -0,0 +1,54 @@
<?php
namespace Alchemy\Phrasea\Command\Developer;
use Alchemy\Phrasea\Command\Command;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
class RegenerateSqliteDb extends Command
{
public function __construct()
{
parent::__construct('phraseanet:regenerate-sqlite');
$this->setDescription("Update the sqlite 'tests/db-ref.sqlite' database with current database definition.");
}
public function doExecute(InputInterface $input, OutputInterface $output)
{
$fs = new Filesystem();
$source = __DIR__ . '/../../../../../tests/db-ref.sqlite';
$target = __DIR__ . '/../../../../../tests/db-ref.sqlite.bkp';
$fs->rename($source, $target);
try {
$dbsParams = $this->container['phraseanet.configuration']->getConnexions();
$dbParams = $dbsParams['test_connexion'];
$dbParams['path'] = $source;
$config = Setup::createYAMLMetadataConfiguration(array(__DIR__ . '/../../../../conf.d/Doctrine'), true);
$em = EntityManager::create($dbParams, $config);
$metadatas = $em->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($em);
$schemaTool->createSchema($metadatas);
} catch (\Exception $e) {
$fs->rename($target, $source);
throw $e;
}
$fs->remove($target);
return 0;
}
}