diff --git a/Command/BuildCommand.php b/Command/BuildCommand.php index d8f1f9b..03207b2 100644 --- a/Command/BuildCommand.php +++ b/Command/BuildCommand.php @@ -11,8 +11,8 @@ namespace Propel\PropelBundle\Command; use Propel\PropelBundle\Command\AbstractPropelCommand; -use Propel\PropelBundle\Command\BuildModelCommand; -use Propel\PropelBundle\Command\BuildSqlCommand; +use Propel\PropelBundle\Command\ModelBuildCommand; +use Propel\PropelBundle\Command\SqlBuildCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; @@ -52,7 +52,7 @@ class BuildCommand extends AbstractPropelCommand protected function execute(InputInterface $input, OutputInterface $output) { if (!$input->getOption('sql')) { - $modelCommand = new BuildModelCommand(); + $modelCommand = new ModelBuildCommand(); $modelCommand->setApplication($this->getApplication()); $modelCommand->execute($input, $output); } @@ -64,7 +64,7 @@ class BuildCommand extends AbstractPropelCommand } if ($input->getOption('insert-sql')) { - $insertCommand = new InsertSqlCommand(); + $insertCommand = new SqlInsertCommand(); $insertCommand->setApplication($this->getApplication()); // By-pass the '--force' required option diff --git a/Command/InitAclCommand.php b/Command/InitAclCommand.php index a3b87f6..cec1daf 100644 --- a/Command/InitAclCommand.php +++ b/Command/InitAclCommand.php @@ -21,7 +21,7 @@ use Symfony\Component\Console\Output\Output; /** * @author Toni Uebernickel */ -class InitAclCommand extends InsertSqlCommand +class InitAclCommand extends SqlInsertCommand { protected function configure() { @@ -30,22 +30,22 @@ class InitAclCommand extends InsertSqlCommand ->addOption('force', null, InputOption::VALUE_NONE, 'Set this parameter to execute this action.') ->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'Set this parameter to define a connection to use') ->setHelp(<<propel:init-acl command connects to the database and executes all SQL statements required to setup the ACL database, it also generates the ACL model. +The %command.name% command connects to the database and executes all SQL statements required to setup the ACL database, it also generates the ACL model. - php app/console propel:init-acl + php %command.full_name% The --force parameter has to be used to actually insert SQL. The --connection parameter allows you to change the connection to use. The default connection is the active connection (propel.dbal.default_connection). EOT ) - ->setName('propel:init-acl') + ->setName('propel:init:acl') ; } protected function execute(InputInterface $input, OutputInterface $output) { - $this->writeSection($output, '[Propel] You are running the command: propel:init-acl'); + $this->writeSection($output, '[Propel] You are running the command: propel:init:acl'); if ($input->getOption('verbose')) { $this->additionalPhingArgs[] = 'verbose'; } @@ -64,7 +64,7 @@ EOT // Prepare SQL directory $sqlDirectory = $this->getSqlDir(); - $filesystem = new Filesystem(); + $filesystem = new Filesystem(); $filesystem->remove($sqlDirectory); $filesystem->mkdir($sqlDirectory); @@ -91,6 +91,9 @@ EOT protected function getSqlDir() { - return $this->getApplication()->getKernel()->getRootDir() . '/cache/' . $this->getApplication()->getKernel()->getEnvironment() . '/propel/acl/sql'; + return sprintf('%s/cache/%s/propel/acl/sql', + $this->getApplication()->getKernel()->getRootDir(), + $this->getApplication()->getKernel()->getEnvironment() + ); } -} \ No newline at end of file +} diff --git a/Command/BuildModelCommand.php b/Command/ModelBuildCommand.php similarity index 81% rename from Command/BuildModelCommand.php rename to Command/ModelBuildCommand.php index 0f3397d..88a2ec2 100644 --- a/Command/BuildModelCommand.php +++ b/Command/ModelBuildCommand.php @@ -15,12 +15,12 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** - * BuildCommand. + * ModelBuildCommand. * * @author Fabien Potencier * @author William DURAND */ -class BuildModelCommand extends AbstractPropelCommand +class ModelBuildCommand extends AbstractPropelCommand { /** * @see Command @@ -30,12 +30,12 @@ class BuildModelCommand extends AbstractPropelCommand $this ->setDescription('Build the Propel Object Model classes based on XML schemas') ->setHelp(<<propel:build-model command builds the Propel runtime model classes (ActiveRecord, Query, Peer, and TableMap classes) based on the XML schemas defined in all Bundles. +The %command.name% command builds the Propel runtime model classes (ActiveRecord, Query, Peer, and TableMap classes) based on the XML schemas defined in all Bundles. - php app/console propel:build-model + php app/console %command.full_name% EOT ) - ->setName('propel:build-model') + ->setName('propel:model:build') ; } @@ -46,7 +46,7 @@ EOT */ protected function execute(InputInterface $input, OutputInterface $output) { - $this->writeSection($output, '[Propel] You are running the command: propel:build-model'); + $this->writeSection($output, '[Propel] You are running the command: propel:model:build'); if ($input->getOption('verbose')) { $this->additionalPhingArgs[] = 'verbose'; diff --git a/Command/BuildSqlCommand.php b/Command/SqlBuildCommand.php similarity index 85% rename from Command/BuildSqlCommand.php rename to Command/SqlBuildCommand.php index 5dba350..05b2c78 100644 --- a/Command/BuildSqlCommand.php +++ b/Command/SqlBuildCommand.php @@ -21,12 +21,12 @@ use Symfony\Component\Finder\Finder; use Propel\PropelBundle\Command\AbstractPropelCommand; /** - * BuildCommand. + * SqlBuildCommand. * * @author Fabien Potencier * @author William DURAND */ -class BuildSqlCommand extends AbstractPropelCommand +class SqlBuildCommand extends AbstractPropelCommand { /** * @see Command @@ -36,12 +36,12 @@ class BuildSqlCommand extends AbstractPropelCommand $this ->setDescription('Build the SQL generation code for all tables based on Propel XML schemas') ->setHelp(<<propel:build-sql command builds the SQL table generation code based on the XML schemas defined in all Bundles. +The %command.name% command builds the SQL table generation code based on the XML schemas defined in all Bundles. - php app/console propel:build-sql + php %command.full_name% EOT ) - ->setName('propel:build-sql') + ->setName('propel:sql:build') ; } @@ -52,7 +52,7 @@ EOT */ protected function execute(InputInterface $input, OutputInterface $output) { - $this->writeSection($output, '[Propel] You are running the command: propel:build-sql'); + $this->writeSection($output, '[Propel] You are running the command: propel:sql:build'); if ($input->getOption('verbose')) { $this->additionalPhingArgs[] = 'verbose'; @@ -94,7 +94,7 @@ EOT $this->writeSection($output, array( '[Propel] Error', '', - 'An error has occured during the "build-sql" task process. To get more details, run the command with the "--verbose" option.' + 'An error has occured during the "%command.name%" command process. To get more details, run the command with the "--verbose" option.' ), 'fg=white;bg=red'); } } diff --git a/Command/InsertSqlCommand.php b/Command/SqlInsertCommand.php similarity index 85% rename from Command/InsertSqlCommand.php rename to Command/SqlInsertCommand.php index 1b192e6..5510f8c 100644 --- a/Command/InsertSqlCommand.php +++ b/Command/SqlInsertCommand.php @@ -16,11 +16,11 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** - * InsertSqlCommand. + * SqlInsertCommand. * * @author William DURAND */ -class InsertSqlCommand extends AbstractPropelCommand +class SqlInsertCommand extends AbstractPropelCommand { /** * @see Command @@ -32,16 +32,16 @@ class InsertSqlCommand extends AbstractPropelCommand ->addOption('force', null, InputOption::VALUE_NONE, 'Set this parameter to execute this action.') ->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'Set this parameter to define a connection to use') ->setHelp(<<propel:insert-sql command connects to the database and executes all SQL statements found in app/propel/sql/*schema.sql. +The %command.name% command connects to the database and executes all SQL statements found in app/propel/sql/*schema.sql. - php app/console propel:insert-sql + php %command.full_name% The --force parameter has to be used to actually insert SQL. The --connection parameter allows you to change the connection to use. The default connection is the active connection (propel.dbal.default_connection). EOT ) - ->setName('propel:insert-sql') + ->setName('propel:sql:insert') ; } @@ -55,7 +55,7 @@ EOT // Bad require but needed :( require_once $this->getContainer()->getParameter('propel.path') . '/generator/lib/util/PropelSqlManager.php'; - $this->writeSection($output, '[Propel] You are running the command: propel:insert-sql'); + $this->writeSection($output, '[Propel] You are running the command: propel:sql:insert'); if ($input->getOption('force')) { if ($input->getOption('verbose')) { @@ -71,12 +71,12 @@ EOT if ($input->getOption('connection')) { list($name, $config) = $this->getConnection($input, $output); - $this->doInsertSql($manager, $output, $name); + $this->doSqlInsert($manager, $output, $name); } else { foreach ($connections as $name => $config) { $output->writeln(sprintf('Use connection named %s in %s environment.', $name, $this->getApplication()->getKernel()->getEnvironment())); - $this->doInsertSql($manager, $output, $name); + $this->doSqlInsert($manager, $output, $name); } } } else { @@ -86,7 +86,7 @@ EOT protected function getSqlDir() { - return $this->getApplication()->getKernel()->getRootDir(). DIRECTORY_SEPARATOR . 'propel'. DIRECTORY_SEPARATOR . 'sql'; + return sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getRootDir()); } /** @@ -94,7 +94,7 @@ EOT * @param OutputInterface $output * @param string $connectionName */ - protected function doInsertSql(\PropelSqlManager $manager, OutputInterface $output, $connectionName) + protected function doSqlInsert(\PropelSqlManager $manager, OutputInterface $output, $connectionName) { try { $statusCode = $manager->insertSql($connectionName); diff --git a/Resources/doc/README.markdown b/Resources/doc/README.markdown index a80cd84..1e28671 100644 --- a/Resources/doc/README.markdown +++ b/Resources/doc/README.markdown @@ -2,22 +2,6 @@ This is the official implementation of [Propel](http://www.propelorm.org/) in Symfony2. -Currently supports: - - * Generation of model classes based on an XML schema (not YAML) placed under `BundleName/Resources/config/*schema.xml`. - * Insertion of SQL statements. - * Runtime autoloading of Propel and generated classes. - * Propel runtime initialization through the XML configuration. - * Migrations [Propel 1.6](http://www.propelorm.org/documentation/10-migrations.html). - * Reverse engineering from [existing database](http://www.propelorm.org/cookbook/working-with-existing-databases.html). - * Integration to the Symfony2 Profiler. - * Load SQL, YAML and XML fixtures. - * Create/Drop databases. - * Integration with the Form component. - * Integration with the Security component. - * Propel ParamConverter can be used with Sensio Framework Extra Bundle. - * Schema Inheritance - ## Installation ## * Clone this bundle in the `vendor/bundles/Propel` directory: @@ -175,9 +159,9 @@ Call the application console with the `propel:build` command: ### Insert SQL ### -Call the application console with the `propel:insert-sql` command: +Call the application console with the `propel:sql:insert` command: - > php app/console propel:insert-sql [--force] + > php app/console propel:sql:insert [--force] Note that the `--force` option is needed to actually execute the SQL statements. @@ -427,7 +411,7 @@ This will switch the provider to be the `AuditableAclProvider` of the `PropelBun The auditing of this provider is set to a sensible default. It will audit all ACL failures but no success by default. If you also want to audit successful authorizations, you need to update the auditing of the given ACL accordingly. -After adding the provider, you only need to run the `propel:init-acl` command in order to get the model generated. +After adding the provider, you only need to run the `propel:init:acl` command in order to get the model generated. If you already got an ACL database, the schema of the `PropelBundle` is compatible with the default schema of Symfony2. ### Separate database connection for ACL ### diff --git a/Tests/TestCase.php b/Tests/TestCase.php index 25625cf..5c10c31 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -33,6 +33,7 @@ class TestCase extends \PHPUnit_Framework_TestCase { return new ContainerBuilder(new ParameterBag(array( 'kernel.debug' => false, + 'kernel.root_dir' => __DIR__ . '/../', ))); }