Skip to content

Commit

Permalink
Merge pull request #473 from jaugustin/1.4
Browse files Browse the repository at this point in the history
Revert "Merge branch '1.5' into 1.4"
  • Loading branch information
jaugustin committed Nov 9, 2017
2 parents f850b01 + 3aa105d commit aa5c65a
Show file tree
Hide file tree
Showing 148 changed files with 5,711 additions and 4,123 deletions.
27 changes: 14 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
sudo: false

language: php

php:
Expand All @@ -11,33 +9,36 @@ php:

cache:
directories:
- $HOME/.composer/cache/files
- $HOME/.composer/cache/files

env:
- SYMFONY_VERSION="^2.8.2"
- SYMFONY_VERSION="^2.8.2" COMPOSER_FLAGS="--prefer-lowest"
- SYMFONY_VERSION="~2.4.0"
- SYMFONY_VERSION="~2.5.0"
- SYMFONY_VERSION="~2.6.0"
- SYMFONY_VERSION="~2.7.0"

matrix:
fast_finish: true

allow_failures:
- php: 7.2
- php: hhvm
include:
- php: 5.3
dist: precise
env: SYMFONY_VERSION="^2.8.2" COMPOSER_FLAGS="--prefer-lowest"
env: SYMFONY_VERSION="~2.7.0"
- php: 5.4
env: SYMFONY_VERSION="^2.8.2"
env: SYMFONY_VERSION="~2.7.0"
- php: 5.5
env: SYMFONY_VERSION="^2.8.2"
env: SYMFONY_VERSION="~2.7.0"

sudo: false

before_install:
- if [ "$TRAVIS_PHP_VERSION" == "5.3" ]; then phpenv config-add travis.php.ini; fi
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi
- if [ "${SYMFONY_VERSION}" != "" ]; then composer require --no-update "symfony/symfony:${SYMFONY_VERSION}"; fi;
- if [ "$TRAVIS_PHP_VERSION" == "5.3" ]; then phpenv config-add travis.php.ini; fi
- if [ "$TRAVIS_PHP_VERSION" == "5.3" ]; then phpenv config-rm xdebug.ini; fi
- composer require --no-update symfony/symfony:${SYMFONY_VERSION}

install:
- composer update ${COMPOSER_FLAGS} --prefer-source
- composer install --prefer-source

script: vendor/bin/phpunit --colors
21 changes: 8 additions & 13 deletions Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* Wrapper for Propel commands.
Expand Down Expand Up @@ -127,13 +128,11 @@ protected function initialize(InputInterface $input, OutputInterface $output)

$this->checkConfiguration();

if ($input->hasArgument('bundle') && $input->getArgument('bundle')) {
$bundleName = $input->getArgument('bundle');
if (0 === strpos($bundleName, '@')) {
$bundleName = substr($bundleName, 1);
}

$this->bundle = $this->getContainer()->get('kernel')->getBundle($bundleName);
if ($input->hasArgument('bundle') && '@' === substr($input->getArgument('bundle'), 0, 1)) {
$this->bundle = $this
->getContainer()
->get('kernel')
->getBundle(substr($input->getArgument('bundle'), 1));
}
}

Expand Down Expand Up @@ -383,10 +382,6 @@ protected function createBuildTimeFile($file)

$propelConfiguration = $container->get('propel.configuration');
foreach ($propelConfiguration['datasources'] as $name => $datasource) {
if (is_scalar($datasource)) {
continue;
}

$xml .= strtr(<<<EOT
<datasource id="%name%">
<adapter>%adapter%</adapter>
Expand Down
95 changes: 95 additions & 0 deletions Command/AclInitCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

/**
* This file is part of the PropelBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/

namespace Propel\PropelBundle\Command;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* @author Toni Uebernickel <tuebernickel@gmail.com>
*/
class AclInitCommand extends SqlInsertCommand
{
protected function configure()
{
$this
->setDescription('Initialize "Access Control Lists" model and SQL')
->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(<<<EOT
The <info>%command.name%</info> command connects to the database and executes all SQL statements required to setup the ACL database, it also generates the ACL model.
<info>php %command.full_name%</info>
The <info>--force</info> parameter has to be used to actually insert SQL.
The <info>--connection</info> parameter allows you to change the connection to use.
The default connection is the active connection (propel.dbal.default_connection).
EOT
)
->setName('propel:acl:init')
;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
// Generate ACL model
if (true == $result = $this->callPhing('om')) {
$output->writeln(sprintf(
'>> <info>%20s</info> Generated model classes from <comment>%s</comment>',
$this->getApplication()->getKernel()->getBundle('PropelBundle')->getName(),
'acl_schema.xml'
));
} else {
$this->writeTaskError($output, 'om');

return 1;
}

// Prepare SQL directory
$sqlDirectory = $this->getSqlDir();
$filesystem = new Filesystem();
$filesystem->remove($sqlDirectory);
$filesystem->mkdir($sqlDirectory);

if (true == $result = $this->callPhing('build-sql', array('propel.sql.dir' => $sqlDirectory))) {
$this->writeSection(
$output,
'<comment>1</comment> <info>SQL file has been generated.</info>'
);
} else {
$this->writeTaskError($output, 'build-sql');

return 2;
}

return parent::execute($input, $output);
}

protected function getFinalSchemas(KernelInterface $kernel, BundleInterface $bundle = null)
{
$aclSchema = new \SplFileInfo($kernel->locateResource('@PropelBundle/Resources/acl_schema.xml'));

return array((string) $aclSchema => array($kernel->getBundle('PropelBundle'), $aclSchema));
}

protected function getSqlDir()
{
return sprintf('%s/cache/%s/propel/acl/sql',
$this->getApplication()->getKernel()->getRootDir(),
$this->getApplication()->getKernel()->getEnvironment()
);
}
}
8 changes: 6 additions & 2 deletions Command/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Propel\PropelBundle\Command\AbstractCommand;

use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output;

/**
* BuildCommand.
Expand Down
6 changes: 4 additions & 2 deletions Command/DatabaseCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Propel\PropelBundle\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;

/**
* DatabaseCreateCommand class.
Expand Down
6 changes: 4 additions & 2 deletions Command/DatabaseDropCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Propel\PropelBundle\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;

/**
* DatabaseDropCommand class.
Expand Down
8 changes: 5 additions & 3 deletions Command/FixturesDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

use Propel\Bundle\PropelBundle\DataFixtures\Dumper\YamlDataDumper;
use Symfony\Component\Console\Input\InputInterface;
namespace Propel\PropelBundle\Command;

use Propel\PropelBundle\Command\AbstractCommand;
use Propel\PropelBundle\DataFixtures\Dumper\YamlDataDumper;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;

Expand Down
11 changes: 7 additions & 4 deletions Command/FixturesLoadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

use Propel\Bundle\PropelBundle\DataFixtures\Loader\XmlDataLoader;
use Propel\Bundle\PropelBundle\DataFixtures\Loader\YamlDataLoader;
namespace Propel\PropelBundle\Command;

use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;

use Propel\PropelBundle\Command\AbstractCommand;
use Propel\PropelBundle\DataFixtures\Loader\YamlDataLoader;
use Propel\PropelBundle\DataFixtures\Loader\XmlDataLoader;

/**
* FixturesLoadCommand
*
Expand Down
8 changes: 3 additions & 5 deletions Command/FormGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -52,11 +53,8 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($schemas = $this->getSchemasFromBundle($this->bundle)) {
$schemas = $this->getFinalSchemas($this->getContainer()->get('kernel'));

$transformer = new \XmlToAppData(null, null, 'UTF-8');
foreach ($schemas as $fileName => $array) {
foreach ($this->getDatabasesFromSchema($array[1], $transformer) as $database) {
foreach ($this->getDatabasesFromSchema($array[1]) as $database) {
$this->createFormTypeFromDatabase($this->bundle, $database, $input->getArgument('models'), $output, $input->getOption('force'));
}
}
Expand Down
10 changes: 4 additions & 6 deletions Command/GeneratorAwareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -38,12 +39,9 @@ protected function loadPropelGenerator()
set_include_path(sprintf('%s/generator/lib', $propelPath) . PATH_SEPARATOR . get_include_path());
}

protected function getDatabasesFromSchema(\SplFileInfo $file, \XmlToAppData $transformer = null)
protected function getDatabasesFromSchema(\SplFileInfo $file)
{
if (null === $transformer) {
$transformer = new \XmlToAppData(null, null, 'UTF-8');
}

$transformer = new \XmlToAppData(null, null, 'UTF-8');
$config = new \QuickGeneratorConfig();

if (file_exists($propelIni = $this->getContainer()->getParameter('kernel.root_dir') . '/config/propel.ini')) {
Expand Down
4 changes: 3 additions & 1 deletion Command/GraphvizGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Propel\PropelBundle\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand Down
4 changes: 3 additions & 1 deletion Command/MigrationGenerateDiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Propel\PropelBundle\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down
4 changes: 3 additions & 1 deletion Command/MigrationMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Propel\PropelBundle\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down
4 changes: 3 additions & 1 deletion Command/MigrationStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
*
* @license MIT License
*/
namespace Propel\Bundle\PropelBundle\Command;

namespace Propel\PropelBundle\Command;

use Propel\PropelBundle\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand Down
Loading

0 comments on commit aa5c65a

Please sign in to comment.