Compare commits
17 commits
3.0.0-alph
...
4.0
Author | SHA1 | Date | |
---|---|---|---|
Simon Vieille | 5e26297485 | ||
Simon Vieille | 892dd63f3a | ||
Simon Vieille | 7c32d28868 | ||
d671fbeb4a | |||
ea6a359272 | |||
af88d81d9a | |||
4df8ff614c | |||
2330aa2e8a | |||
d5f4435ce0 | |||
59f3b4a738 | |||
efada49f15 | |||
9536a719e3 | |||
61ef13c803 | |||
5ea4110b62 | |||
c4359c39b6 | |||
df24480a4f | |||
0d0d6c1c65 |
19
.travis.yml
19
.travis.yml
|
@ -3,33 +3,26 @@ sudo: false
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- nightly
|
||||
- hhvm
|
||||
- 7.1
|
||||
- 7.2
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache/files
|
||||
|
||||
env:
|
||||
- SYMFONY_VERSION="^2.8"
|
||||
- SYMFONY_VERSION="^2.8" COMPOSER_FLAGS="--prefer-lowest"
|
||||
- SYMFONY_VERSION="^3.0"
|
||||
- SYMFONY_VERSION="^3.0" COMPOSER_FLAGS="--prefer-lowest"
|
||||
- SYMFONY_VERSION="dev-master"
|
||||
- SYMFONY_VERSION="^4.0"
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
- php: nightly
|
||||
- env: SYMFONY_VERSION="dev-master"
|
||||
exclude:
|
||||
- php: 7.0
|
||||
env: SYMFONY_VERSION="^4.0"
|
||||
|
||||
before_install:
|
||||
- phpenv config-rm xdebug.ini
|
||||
- composer self-update
|
||||
- if [ "${SYMFONY_VERSION}" != "" ]; then composer require --no-update "symfony/symfony:${SYMFONY_VERSION}"; fi;
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@ abstract class AbstractCommand extends ContainerAwareCommand
|
|||
*/
|
||||
protected $output;
|
||||
|
||||
protected $tempSchemas = [];
|
||||
|
||||
use FormattingHelpers;
|
||||
|
||||
/**
|
||||
|
@ -96,17 +94,15 @@ abstract class AbstractCommand extends ContainerAwareCommand
|
|||
|
||||
$finalSchemas = $this->getFinalSchemas($kernel, $this->bundle);
|
||||
foreach ($finalSchemas as $schema) {
|
||||
/** @var Bundle $bundle */
|
||||
/** @var null|Bundle $bundle */
|
||||
list($bundle, $finalSchema) = $schema;
|
||||
|
||||
$tempSchema = $bundle->getName().'-'.$finalSchema->getBaseName();
|
||||
$this->tempSchemas[$tempSchema] = array(
|
||||
'bundle' => $bundle->getName(),
|
||||
'basename' => $finalSchema->getBaseName(),
|
||||
'path' => $finalSchema->getPathname(),
|
||||
);
|
||||
if ($bundle) {
|
||||
$file = $cacheDir.DIRECTORY_SEPARATOR.'bundle-'.$bundle->getName().'-'.$finalSchema->getBaseName();
|
||||
} else {
|
||||
$file = $cacheDir.DIRECTORY_SEPARATOR.'app-'.$finalSchema->getBaseName();
|
||||
}
|
||||
|
||||
$file = $cacheDir.DIRECTORY_SEPARATOR.$tempSchema;
|
||||
$filesystem->copy((string) $finalSchema, $file, true);
|
||||
|
||||
// the package needs to be set absolute
|
||||
|
@ -119,12 +115,18 @@ abstract class AbstractCommand extends ContainerAwareCommand
|
|||
// This is used to override the package resulting from namespace conversion.
|
||||
$database['package'] = $database['package'];
|
||||
} elseif (isset($database['namespace'])) {
|
||||
|
||||
$database['package'] = $this->getPackageFromBundle($bundle, (string)$database['namespace']);
|
||||
if ($bundle) {
|
||||
$database['package'] = $this->getPackageFromBundle($bundle, (string)$database['namespace']);
|
||||
} else {
|
||||
$database['package'] = $this->getPackageFromApp((string)$database['namespace']);
|
||||
}
|
||||
} else {
|
||||
throw new \RuntimeException(
|
||||
sprintf('%s : Please define a `package` attribute or a `namespace` attribute for schema `%s`',
|
||||
$bundle->getName(), $finalSchema->getBaseName())
|
||||
sprintf(
|
||||
'%s : Please define a `package` attribute or a `namespace` attribute for schema `%s`',
|
||||
$bundle ? $bundle->getName() : 'App',
|
||||
$finalSchema->getBaseName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -134,7 +136,6 @@ abstract class AbstractCommand extends ContainerAwareCommand
|
|||
if (!in_array((string) $database['name'], $connections)) {
|
||||
// we skip this schema because the connection name doesn't
|
||||
// match the input values
|
||||
unset($this->tempSchemas[$tempSchema]);
|
||||
$filesystem->remove($file);
|
||||
$this->output->writeln(sprintf(
|
||||
'<info>Skipped schema %s due to database name missmatch (%s not in [%s]).</info>',
|
||||
|
@ -150,7 +151,11 @@ abstract class AbstractCommand extends ContainerAwareCommand
|
|||
if (isset($table['package'])) {
|
||||
$table['package'] = $table['package'];
|
||||
} elseif (isset($table['namespace'])) {
|
||||
$table['package'] = $this->getPackageFromBundle($bundle, (string)$table['namespace']);
|
||||
if ($bundle) {
|
||||
$table['package'] = $this->getPackageFromBundle($bundle, (string)$table['namespace']);
|
||||
} else {
|
||||
$table['package'] = $this->getPackageFromApp((string)$table['namespace']);
|
||||
}
|
||||
} else {
|
||||
$table['package'] = $database['package'];
|
||||
}
|
||||
|
@ -175,7 +180,7 @@ abstract class AbstractCommand extends ContainerAwareCommand
|
|||
return $this->getSchemaLocator()->locateFromBundle($bundle);
|
||||
}
|
||||
|
||||
return $this->getSchemaLocator()->locateFromBundles($kernel->getBundles());
|
||||
return $this->getSchemaLocator()->locateFromBundlesAndConfiguration($kernel->getBundles());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -304,6 +309,24 @@ abstract class AbstractCommand extends ContainerAwareCommand
|
|||
return $this->getContainer()->get('propel.schema_locator');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getPackageFromApp($namespace)
|
||||
{
|
||||
if ('\\' === $namespace[0]) {
|
||||
$namespace = substr($namespace, 1);
|
||||
}
|
||||
|
||||
if (0 === stripos($namespace, 'App\\')) {
|
||||
$namespace = substr($namespace, 4);
|
||||
}
|
||||
|
||||
return 'src.'.str_replace('\\', '.', $namespace);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Bundle $bundle
|
||||
* @param string $namespace
|
||||
|
@ -384,10 +407,10 @@ abstract class AbstractCommand extends ContainerAwareCommand
|
|||
*/
|
||||
protected function parseDbName($dsn)
|
||||
{
|
||||
preg_match('#dbname=([a-zA-Z0-9\_]+)#', $dsn, $matches);
|
||||
preg_match('#(dbname|Database)=([a-zA-Z0-9\_]+)#', $dsn, $matches);
|
||||
|
||||
if (isset($matches[1])) {
|
||||
return $matches[1];
|
||||
if (isset($matches[2])) {
|
||||
return $matches[2];
|
||||
}
|
||||
|
||||
// e.g. SQLite
|
||||
|
|
|
@ -83,7 +83,7 @@ class DatabaseCreateCommand extends AbstractCommand
|
|||
$dbName = $this->parseDbName($config['dsn']);
|
||||
|
||||
$config['dsn'] = preg_replace(
|
||||
'#;?dbname='.$dbName.'#',
|
||||
'#;?(dbname|Database)='.$dbName.'#',
|
||||
'',
|
||||
$config['dsn']
|
||||
);
|
||||
|
|
|
@ -14,6 +14,7 @@ use Propel\Runtime\Propel;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Propel\Runtime\Connection\ConnectionManagerSingle;
|
||||
|
||||
/**
|
||||
* DatabaseDropCommand class.
|
||||
|
@ -79,9 +80,41 @@ EOT
|
|||
$query = 'DROP DATABASE '. $dbName .';';
|
||||
}
|
||||
|
||||
|
||||
$manager = new ConnectionManagerSingle();
|
||||
$manager->setConfiguration($this->getTemporaryConfiguration($config));
|
||||
|
||||
$serviceContainer = Propel::getServiceContainer();
|
||||
$serviceContainer->setAdapterClass($connectionName, $config['adapter']);
|
||||
$serviceContainer->setConnectionManager($connectionName, $manager);
|
||||
|
||||
$connection = Propel::getConnection($connectionName);
|
||||
|
||||
$statement = $connection->prepare($query);
|
||||
$statement->execute();
|
||||
|
||||
$output->writeln(sprintf('<info>Database <comment>%s</comment> has been dropped.</info>', $dbName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a temporary configuration to connect to the database in order
|
||||
* to create a given database. This idea comes from Doctrine1.
|
||||
*
|
||||
* @see https://github.com/doctrine/doctrine1/blob/master/lib/Doctrine/Connection.php#L1491
|
||||
*
|
||||
* @param array $config A Propel connection configuration.
|
||||
* @return array
|
||||
*/
|
||||
private function getTemporaryConfiguration($config)
|
||||
{
|
||||
$dbName = $this->parseDbName($config['dsn']);
|
||||
|
||||
$config['dsn'] = preg_replace(
|
||||
'#;?(dbname|Database)='.$dbName.'#',
|
||||
'',
|
||||
$config['dsn']
|
||||
);
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class MigrationDiffCommand extends WrappedCommand
|
|||
*/
|
||||
protected function getSubCommandArguments(InputInterface $input)
|
||||
{
|
||||
$defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations';
|
||||
$defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir'];
|
||||
|
||||
return array(
|
||||
'--connection' => $this->getConnections($input->getOption('connection')),
|
||||
|
|
|
@ -52,7 +52,7 @@ class MigrationDownCommand extends WrappedCommand
|
|||
*/
|
||||
protected function getSubCommandArguments(InputInterface $input)
|
||||
{
|
||||
$defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations';
|
||||
$defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir'];
|
||||
|
||||
return array(
|
||||
'--connection' => $this->getConnections($input->getOption('connection')),
|
||||
|
|
|
@ -52,7 +52,7 @@ class MigrationMigrateCommand extends WrappedCommand
|
|||
*/
|
||||
protected function getSubCommandArguments(InputInterface $input)
|
||||
{
|
||||
$defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations';
|
||||
$defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir'];
|
||||
|
||||
return array(
|
||||
'--connection' => $this->getConnections($input->getOption('connection')),
|
||||
|
|
|
@ -50,7 +50,7 @@ class MigrationStatusCommand extends WrappedCommand
|
|||
*/
|
||||
protected function getSubCommandArguments(InputInterface $input)
|
||||
{
|
||||
$defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations';
|
||||
$defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir'];
|
||||
|
||||
return array(
|
||||
'--connection' => $this->getConnections($input->getOption('connection')),
|
||||
|
|
|
@ -52,7 +52,7 @@ class MigrationUpCommand extends WrappedCommand
|
|||
*/
|
||||
protected function getSubCommandArguments(InputInterface $input)
|
||||
{
|
||||
$defaultOutputDir = $this->getApplication()->getKernel()->getRootDir().'/propel/migrations';
|
||||
$defaultOutputDir = $this->getContainer()->getParameter('propel.configuration')['paths']['migrationDir'];
|
||||
|
||||
return array(
|
||||
'--connection' => $this->getConnections($input->getOption('connection')),
|
||||
|
|
|
@ -47,7 +47,7 @@ class SqlBuildCommand extends WrappedCommand
|
|||
*/
|
||||
protected function getSubCommandArguments(InputInterface $input)
|
||||
{
|
||||
$defaultSqlDir = sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getRootDir());
|
||||
$defaultSqlDir = $this->getContainer()->getParameter('propel.configuration')['paths']['sqlDir'];
|
||||
|
||||
return array(
|
||||
'--connection' => $this->getConnections($input->getOption('connection')),
|
||||
|
|
|
@ -59,7 +59,7 @@ class SqlInsertCommand extends WrappedCommand
|
|||
*/
|
||||
protected function getSubCommandArguments(InputInterface $input)
|
||||
{
|
||||
$defaultSqlDir = sprintf('%s/propel/sql', $this->getApplication()->getKernel()->getRootDir());
|
||||
$defaultSqlDir = $this->getContainer()->getParameter('propel.configuration')['paths']['sqlDir'];
|
||||
|
||||
return array(
|
||||
'--connection' => $this->getConnections($input->getOption('connection')),
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
namespace Propel\Bundle\PropelBundle\Controller;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
@ -20,23 +21,19 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
*
|
||||
* @author William DURAND <william.durand1@gmail.com>
|
||||
*/
|
||||
class PanelController implements ContainerAwareInterface
|
||||
class PanelController extends Controller
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
/**
|
||||
* This method renders the global Propel configuration.
|
||||
*/
|
||||
public function configurationAction()
|
||||
{
|
||||
$templating = $this->container->get('templating');
|
||||
|
||||
return $templating->renderResponse(
|
||||
'PropelBundle:Panel:configuration.html.twig',
|
||||
return $this->render(
|
||||
'@Propel/Panel/configuration.html.twig',
|
||||
array(
|
||||
'propel_version' => Propel::VERSION,
|
||||
'configuration' => $this->container->getParameter('propel.configuration'),
|
||||
'logging' => $this->container->getParameter('propel.logging'),
|
||||
'configuration' => $this->getParameter('propel.configuration'),
|
||||
'logging' => $this->getParameter('propel.logging'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -52,7 +49,7 @@ class PanelController implements ContainerAwareInterface
|
|||
*/
|
||||
public function explainAction($token, $connection, $query)
|
||||
{
|
||||
$profiler = $this->container->get('profiler');
|
||||
$profiler = $this->get('profiler');
|
||||
$profiler->disable();
|
||||
|
||||
$profile = $profiler->loadProfile($token);
|
||||
|
@ -73,8 +70,8 @@ class PanelController implements ContainerAwareInterface
|
|||
return new Response('<div class="error">This query cannot be explained.</div>');
|
||||
}
|
||||
|
||||
return $this->container->get('templating')->renderResponse(
|
||||
'PropelBundle:Panel:explain.html.twig',
|
||||
return $this->render(
|
||||
'@Propel/Panel/explain.html.twig',
|
||||
array(
|
||||
'data' => $results,
|
||||
'query' => $query,
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
/**
|
||||
* 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\Bundle\PropelBundle\DataCollector;
|
||||
|
@ -36,7 +35,7 @@ class PropelDataCollector extends DataCollector
|
|||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||
{
|
||||
$this->data = array(
|
||||
'queries' => $this->buildQueries(),
|
||||
'queries' => $this->cloneVar($this->buildQueries()),
|
||||
'querycount' => $this->countQueries(),
|
||||
);
|
||||
}
|
||||
|
@ -105,4 +104,12 @@ class PropelDataCollector extends DataCollector
|
|||
{
|
||||
return count($this->logger->getQueries());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
// TODO: Implement reset() method.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ abstract class AbstractDataDumper extends AbstractDataHandler implements DataDum
|
|||
}
|
||||
$stmt = $this
|
||||
->con
|
||||
->query(sprintf('SELECT %s FROM %s', implode(',', $in), constant(constant($tableName.'::TABLE_MAP').'::TABLE_NAME')));
|
||||
->query(sprintf('SELECT `%s` FROM `%s`', implode('`, `', $in), constant(constant($tableName.'::TABLE_MAP').'::TABLE_NAME')));
|
||||
|
||||
$set = array();
|
||||
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
|
|
@ -28,8 +28,7 @@ class YamlDataDumper extends AbstractDataDumper
|
|||
$data,
|
||||
$inline = 3,
|
||||
$indent = 4,
|
||||
$exceptionOnInvalidType = false,
|
||||
$objectSupport = true
|
||||
Yaml::DUMP_OBJECT
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,30 @@ use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
|||
class Configuration extends PropelConfiguration
|
||||
{
|
||||
private $debug;
|
||||
private $defaultDir;
|
||||
|
||||
public function __construct($debug = true)
|
||||
public function __construct($debug, $kernelDir)
|
||||
{
|
||||
$this->debug = $debug;
|
||||
$this->defaultDir = $kernelDir.'/propel';
|
||||
}
|
||||
|
||||
protected function addPathsSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
->children()
|
||||
->arrayNode('paths')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('schemaDir')->defaultValue($this->defaultDir)->end()
|
||||
->scalarNode('sqlDir')->defaultValue($this->defaultDir.'/sql')->end()
|
||||
->scalarNode('migrationDir')->defaultValue($this->defaultDir.'/migrations')->end()
|
||||
->scalarNode('phpConfDir')->defaultValue($this->defaultDir.'/generated-conf')->end()
|
||||
->scalarNode('composerDir')->defaultNull()->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
|
||||
protected function addRuntimeSection(ArrayNodeDefinition $node)
|
||||
|
@ -161,6 +181,7 @@ class Configuration extends PropelConfiguration
|
|||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->booleanNode('ATTR_EMULATE_PREPARES')->defaultFalse()->end()
|
||||
->scalarNode('SQLSRV_ATTR_ENCODING')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('model_paths')
|
||||
|
|
|
@ -15,7 +15,6 @@ use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
|||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
|
||||
/**
|
||||
* PropelExtension loads the PropelBundle configuration.
|
||||
|
@ -32,9 +31,8 @@ class PropelExtension extends Extension
|
|||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$processor = new Processor();
|
||||
$configuration = $this->getConfiguration($configs, $container);
|
||||
$config = $processor->processConfiguration($configuration, $configs);
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
if (1 === count($config['database']['connections'])) {
|
||||
$defaultConnection = array_keys($config['database']['connections'])[0];
|
||||
|
@ -55,12 +53,13 @@ class PropelExtension extends Extension
|
|||
$loader->load('propel.xml');
|
||||
$loader->load('converters.xml');
|
||||
$loader->load('security.xml');
|
||||
$loader->load('console.xml');
|
||||
}
|
||||
}
|
||||
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
{
|
||||
return new Configuration($container->getParameter('kernel.debug'));
|
||||
return new Configuration($container->getParameter('kernel.debug'), $container->getParameter('kernel.root_dir'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Propel\Bundle\PropelBundle\DependencyInjection\Security\UserProvider;
|
|||
|
||||
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
|
||||
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
/**
|
||||
* PropelFactory creates services for Propel user provider.
|
||||
|
@ -30,7 +30,7 @@ class PropelFactory implements UserProviderFactoryInterface
|
|||
public function create(ContainerBuilder $container, $id, $config)
|
||||
{
|
||||
$container
|
||||
->setDefinition($id, new DefinitionDecorator($this->providerId))
|
||||
->setDefinition($id, new ChildDefinition($this->providerId))
|
||||
->addArgument($config['class'])
|
||||
->addArgument($config['property'])
|
||||
;
|
||||
|
|
|
@ -214,9 +214,13 @@ class ModelType extends AbstractType
|
|||
$valueProperty = $options['property'];
|
||||
/** @var ModelCriteria $query */
|
||||
$query = $options['query'];
|
||||
$getter = 'get' . ucfirst($query->getTableMap()->getColumn($valueProperty)->getPhpName());
|
||||
|
||||
$choiceLabel = function($choice) use ($getter) {
|
||||
$choiceLabel = function($choice) use ($valueProperty) {
|
||||
$getter = 'get'.ucfirst($valueProperty);
|
||||
if (!method_exists($choice, $getter)) {
|
||||
$getter = 'get' . ucfirst($query->getTableMap()->getColumn($valueProperty)->getPhpName());
|
||||
}
|
||||
|
||||
return call_user_func([$choice, $getter]);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace Propel\Bundle\PropelBundle\Logger;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use Psr\Log\LoggerTrait;
|
||||
use Symfony\Component\Stopwatch\Stopwatch;
|
||||
use Symfony\Component\VarDumper\Caster\TraceStub;
|
||||
|
||||
/**
|
||||
* @author Kévin Gomez <contact@kevingomez.fr>
|
||||
|
@ -64,10 +65,9 @@ class PropelLogger implements LoggerInterface
|
|||
}
|
||||
|
||||
$add = true;
|
||||
$stackTrace = $this->getStackTrace();
|
||||
$trace = debug_backtrace();
|
||||
|
||||
if (null !== $this->stopwatch) {
|
||||
$trace = debug_backtrace();
|
||||
$method = $trace[3]['function'];
|
||||
|
||||
$watch = 'Propel Query '.(count($this->queries)+1);
|
||||
|
@ -91,7 +91,7 @@ class PropelLogger implements LoggerInterface
|
|||
'connection' => $connection->getName(),
|
||||
'time' => $event->getDuration() / 1000,
|
||||
'memory' => $event->getMemory(),
|
||||
'stackTrace' => $stackTrace,
|
||||
'trace' => new TraceStub($trace),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -102,25 +102,4 @@ class PropelLogger implements LoggerInterface
|
|||
{
|
||||
return $this->queries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current stack trace.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getStackTrace()
|
||||
{
|
||||
$e = new \Exception();
|
||||
$trace = explode("\n", $e->getTraceAsString());
|
||||
$trace = array_reverse($trace);
|
||||
array_shift($trace); // remove {main}
|
||||
array_pop($trace); // remove call to this method
|
||||
|
||||
foreach ($trace as $i => &$value) {
|
||||
$value = $i + 1 . ')' . substr($value, strpos($value, ' '));
|
||||
$value = preg_replace('/\((\d+)\)/', ':$1', $value, 1);
|
||||
}
|
||||
|
||||
return $trace;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,8 @@ class PropelBundle extends Bundle
|
|||
$serviceContainer->setAdapterClass($name, $config['adapter']);
|
||||
$serviceContainer->setConnectionManager($name, $manager);
|
||||
}
|
||||
|
||||
$serviceContainer->initDatabaseMaps([]);
|
||||
}
|
||||
|
||||
protected function configureLogging()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PropelBundle
|
||||
============
|
||||
|
||||
[![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=3.0)](https://travis-ci.org/propelorm/PropelBundle)
|
||||
[![Build Status](https://travis-ci.org/propelorm/PropelBundle.svg?branch=4.0)](https://travis-ci.org/propelorm/PropelBundle)
|
||||
|
||||
This is the official implementation of [Propel](http://www.propelorm.org/) in Symfony.
|
||||
|
||||
|
@ -12,8 +12,9 @@ As `Propel2` will be released in the near future, we are migrating the branching
|
|||
* The `1.0` branch contains Propel *1.6* integration for Symfony *2.0* (*currently 2.0 branch*).
|
||||
* The `1.1` branch contains Propel *1.6* integration for Symfony *2.1* (*currently 2.1 branch*).
|
||||
* The `1.2` branch contains Propel *1.6* integration for Symfony *2.2* (*currently master branch*).
|
||||
* The `2.0` branch contains `Propel2` integration for Symfony *2*.
|
||||
* The `3.0` branch contains `Propel2` integration for Symfony *3*.
|
||||
* The `2.0` branch contains `Propel2` integration for Symfony *2.5-2.8*.
|
||||
* The `3.0` branch contains `Propel2` integration for Symfony *2.8-3.x*.
|
||||
* The `4.0` branch contains `Propel2` integration for Symfony *3.4-4.x*.
|
||||
|
||||
## Features
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|||
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
|
||||
/**
|
||||
* PropelParamConverter
|
||||
|
@ -60,16 +59,6 @@ class PropelParamConverter implements ParamConverterInterface
|
|||
*/
|
||||
protected $hasWith = false;
|
||||
|
||||
/**
|
||||
* @var RouterInterface
|
||||
*/
|
||||
protected $router;
|
||||
|
||||
public function setRouter(RouterInterface $router = null)
|
||||
{
|
||||
$this->router = $router;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param ParamConverter $configuration
|
||||
|
@ -102,9 +91,9 @@ class PropelParamConverter implements ParamConverterInterface
|
|||
|
||||
$options = $configuration->getOptions();
|
||||
|
||||
// Check route options for converter options, if there are non provided.
|
||||
if (empty($options) && $request->attributes->has('_route') && $this->router && $configuration instanceof ParamConverter) {
|
||||
$converterOption = $this->router->getRouteCollection()->get($request->attributes->get('_route'))->getOption('propel_converter');
|
||||
// Check request attributes for converter options, if there are non provided.
|
||||
if (empty($options) && $request->attributes->has('propel_converter') && $configuration instanceof ParamConverter) {
|
||||
$converterOption = $request->attributes->get('propel_converter');
|
||||
if (!empty($converterOption[$configuration->getName()])) {
|
||||
$options = $converterOption[$configuration->getName()];
|
||||
}
|
||||
|
|
78
Resources/config/console.xml
Normal file
78
Resources/config/console.xml
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0" ?>
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
<services>
|
||||
<service id="propel_bundle_propel.command.acl_init_command" class="Propel\Bundle\PropelBundle\Command\AclInitCommand">
|
||||
<tag name="console.command" command="propel:acl:init" />
|
||||
</service>
|
||||
<service id="propel_bundle_propel.command.build_command" class="Propel\Bundle\PropelBundle\Command\BuildCommand">
|
||||
<tag name="console.command" command="propel:build" />
|
||||
</service>
|
||||
<service id="propel_bundle_propel.command.database_create_command" class="Propel\Bundle\PropelBundle\Command\DatabaseCreateCommand">
|
||||
<tag name="console.command" command="propel:database:create" />
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\DatabaseDropCommand"
|
||||
id="propel_bundle_propel.command.database_drop_command">
|
||||
<tag name="console.command" command="propel:database:drop"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\DatabaseReverseCommand"
|
||||
id="propel_bundle_propel.command.database_reverse_command">
|
||||
<tag name="console.command" command="propel:database:reverse"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\FixturesDumpCommand"
|
||||
id="propel_bundle_propel.command.fixtures_dump_command">
|
||||
<tag name="console.command" command="propel:fixtures:dump"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\FixturesLoadCommand"
|
||||
id="propel_bundle_propel.command.fixtures_load_command">
|
||||
<tag name="console.command" command="propel:fixtures:load"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\FormGenerateCommand"
|
||||
id="propel_bundle_propel.command.form_generate_command">
|
||||
<tag name="console.command" command="propel:form:generate"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\GraphvizGenerateCommand"
|
||||
id="propel_bundle_propel.command.graphviz_generate_command">
|
||||
<tag name="console.command" command="propel:graphviz:generate"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\MigrationDiffCommand"
|
||||
id="propel_bundle_propel.command.migration_diff_command">
|
||||
<tag name="console.command" command="propel:migration:diff"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\MigrationDownCommand"
|
||||
id="propel_bundle_propel.command.migration_down_command">
|
||||
<tag name="console.command" command="propel:migration:down"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\MigrationMigrateCommand"
|
||||
id="propel_bundle_propel.command.migration_migrate_command">
|
||||
<tag name="console.command" command="propel:migration:migrate"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\MigrationStatusCommand"
|
||||
id="propel_bundle_propel.command.migration_status_command">
|
||||
<tag name="console.command" command="propel:migration:status"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\MigrationUpCommand"
|
||||
id="propel_bundle_propel.command.migration_up_command">
|
||||
<tag name="console.command" command="propel:migration:up"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\ModelBuildCommand"
|
||||
id="propel_bundle_propel.command.model_build_command">
|
||||
<tag name="console.command" command="propel:model:build"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\SqlBuildCommand"
|
||||
id="propel_bundle_propel.command.sql_build_command">
|
||||
<tag name="console.command" command="propel:sql:build"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\SqlInsertCommand"
|
||||
id="propel_bundle_propel.command.sql_insert_command">
|
||||
<tag name="console.command" command="propel:sql:insert"/>
|
||||
</service>
|
||||
<service class="Propel\Bundle\PropelBundle\Command\TableDropCommand"
|
||||
id="propel_bundle_propel.command.table_drop_command">
|
||||
<tag name="console.command" command="propel:table:drop"/>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
|
@ -11,10 +11,6 @@
|
|||
<services>
|
||||
<service id="propel.converter.propel.orm" class="%propel.converter.propel.class%">
|
||||
<tag name="request.param_converter" converter="propel" priority="1" />
|
||||
|
||||
<call method="setRouter">
|
||||
<argument type="service" id="router" on-invalid="null" />
|
||||
</call>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
@ -19,11 +19,12 @@
|
|||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="propel.schema_locator" class="%propel.schema_locator.class%">
|
||||
<service id="propel.schema_locator" class="%propel.schema_locator.class%" public="true">
|
||||
<argument type="service" id="file_locator" />
|
||||
<argument>%propel.configuration%</argument>
|
||||
</service>
|
||||
|
||||
<service id="propel.logger" class="%propel.logger.class%">
|
||||
<service id="propel.logger" class="%propel.logger.class%" public="true">
|
||||
<tag name="monolog.logger" channel="propel" />
|
||||
<argument type="service" id="logger" on-invalid="null" />
|
||||
<argument type="service" id="debug.stopwatch" on-invalid="null" />
|
||||
|
@ -31,7 +32,7 @@
|
|||
|
||||
<service id="propel.data_collector" class="%propel.data_collector.class%" public="false">
|
||||
<argument type="service" id="propel.logger" />
|
||||
<tag name="data_collector" template="PropelBundle:Collector:propel" id="propel" />
|
||||
<tag name="data_collector" template="@Propel/Collector/propel" id="propel" />
|
||||
</service>
|
||||
|
||||
<service id="propel.twig.extension.syntax" class="%propel.twig.extension.syntax.class%">
|
||||
|
@ -61,5 +62,7 @@
|
|||
<argument>%kernel.root_dir%</argument>
|
||||
<argument>%propel.configuration%</argument>
|
||||
</service>
|
||||
|
||||
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
@ -1,33 +1,39 @@
|
|||
{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}
|
||||
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
|
||||
|
||||
{% block toolbar %}
|
||||
{# the web debug toolbar content #}
|
||||
{% set icon %}
|
||||
<img alt="Propel" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAcCAYAAAB2+A+pAAACzmlDQ1BJQ0MgUHJvZmlsZQAAeNqNk8trFFkUh7/q3KCQIAy0r14Ml1lIkCSUDzQiPtJJbKKxbcpEkyBIp/p2d5mb6ppb1XEUEcnGpc4we/GxcOEf4MKFK90oEXwhiHsVRRTcqLSL6nRX8HlWX/3Oub9zzi0udNrFINApCXN+ZJxcVk5OTcsVz0ixni4ydBXdMBgsFMYAikGg+SY+PsECeNj3/fxPo6sUunNgrYTU+5IKXej4DNQqk1PTIDSQPhkFEYhzQNrE+v9Aeibm60DajDtDIG4Bq9zARCDuAQNutViCTgH0VhI1Mwme03W3Oc8fQLfyJw4DGyB1VoUjTbYWSsXhA0A/WK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cz/NnBEEolyQJlFKoqgpK6Yqqx3Q63RdNTU1tO7l0nmDc1dVFGhoa1GVAY1dX13vz8/MXRFEsWwFavoGiOp2uW6/XX1dVtdflcnFOp5MDgM7OTmi1WjQ2Nm4NHAgEUFVVheHhYRIOh8mpU6cUALh582ZrNBr9kuf5XQzDgBAyYzQapzUazc9VVVUD+/fv/32zhN3d3fB6vdsz5jgOVqt11XDjxo13U6nURUpphSRJI3l5eX0ajab76NGjd61W68PNkrS3t8PtduPAgQM7bibI0NAQ3G43gsFgUywWuygIgqooym9arbbD6/VOEkJWr7qysjLS1tZG7Xa74nQ61efuEkOhUOHExMSJ/v5+22bz0Wj0xffAoVBoU3tBQcFTm/LnHQQAHj16BEVRiKIoqsvl+k9eGn8BMMeiAFTierUAAAAASUVORK5CYII=" />
|
||||
<span class="sf-toolbar-status">{{ collector.querycount }}</span>
|
||||
{% endset %}
|
||||
{% set text %}
|
||||
<div class="sf-toolbar-info-piece">
|
||||
<b>DB Queries</b>
|
||||
<span>{{ collector.querycount }}</span>
|
||||
</div>
|
||||
<div class="sf-toolbar-info-piece">
|
||||
<b>Query time</b>
|
||||
<span>{{ '%0.2f'|format(collector.time * 1000) }} ms</span>
|
||||
</div>
|
||||
{% endset %}
|
||||
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %}
|
||||
{% if collector.querycount %}
|
||||
{% set icon %}
|
||||
<img alt="Propel" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAcCAYAAAB2+A+pAAACzmlDQ1BJQ0MgUHJvZmlsZQAAeNqNk8trFFkUh7/q3KCQIAy0r14Ml1lIkCSUDzQiPtJJbKKxbcpEkyBIp/p2d5mb6ppb1XEUEcnGpc4we/GxcOEf4MKFK90oEXwhiHsVRRTcqLSL6nRX8HlWX/3Oub9zzi0udNrFINApCXN+ZJxcVk5OTcsVz0ixni4ydBXdMBgsFMYAikGg+SY+PsECeNj3/fxPo6sUunNgrYTU+5IKXej4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xfEVleXl5mz5497xNCFp+mnydKHYvFSGFhobrFeW3p7+9/M51OX8pkMqUralYURQFA9Xo9bDbb6YaGhm/dbjd8Ph+Kioq2B15YWIDJZNpsP7M+n+8Cz/NnBEEolyQJlFKoqgpK6Yqqx3Q63RdNTU1tO7l0nmDc1dVFGhoa1GVAY1dX13vz8/MXRFEsWwFavoGiOp2uW6/XX1dVtdflcnFOp5MDgM7OTmi1WjQ2Nm4NHAgEUFVVheHhYRIOh8mpU6cUALh582ZrNBr9kuf5XQzDgBAyYzQapzUazc9VVVUD+/fv/32zhN3d3fB6vdsz5jgOVqt11XDjxo13U6nURUpphSRJI3l5eX0ajab76NGjd61W68PNkrS3t8PtduPAgQM7bibI0NAQ3G43gsFgUywWuygIgqooym9arbbD6/VOEkJWr7qysjLS1tZG7Xa74nQ61efuEkOhUOHExMSJ/v5+22bz0Wj0xffAoVBoU3tBQcFTm/LnHQQAHj16BEVRiKIoqsvl+k9eGn8BMMeiAFTierUAAAAASUVORK5CYII=" />
|
||||
<span class="sf-toolbar-value">{{ collector.querycount }}</span>
|
||||
<span class="sf-toolbar-info-piece-additional-detail">
|
||||
<span class="sf-toolbar-label">in</span>
|
||||
<span class="sf-toolbar-value">{{ '%0.2f'|format(collector.time * 1000) }}</span>
|
||||
<span class="sf-toolbar-label">ms</span>
|
||||
</span>
|
||||
{% endset %}
|
||||
{% set text %}
|
||||
<div class="sf-toolbar-info-piece">
|
||||
<b>DB Queries</b>
|
||||
<span class="sf-toolbar-status {{ collector.querycount > 50 ? 'sf-toolbar-status-yellow' : '' }}">{{ collector.querycount }}</span>
|
||||
</div>
|
||||
<div class="sf-toolbar-info-piece">
|
||||
<b>Query time</b>
|
||||
<span>{{ '%0.2f'|format(collector.time * 1000) }} ms</span>
|
||||
</div>
|
||||
{% endset %}
|
||||
|
||||
{% set status = collector.querycount > 50 ? 'yellow' : '' %}
|
||||
|
||||
{% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url, status: status } %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block menu %}
|
||||
{# the menu content #}
|
||||
<span class="label">
|
||||
<span class="label {{ not collector.querycount ? 'disabled' }}">
|
||||
<span class="icon"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAcCAYAAAB2+A+pAAACzmlDQ1BJQ0MgUHJvZmlsZQAAeNqNk8trFFkUh7/q3KCQIAy0r14Ml1lIkCSUDzQiPtJJbKKxbcpEkyBIp/p2d5mb6ppb1XEUEcnGpc4we/GxcOEf4MKFK90oEXwhiHsVRRTcqLSL6nRX8HlWX/3Oub9zzi0udNrFINApCXN+ZJxcVk5OTcsVz0ixni4ydBXdMBgsFMYAikGg+SY+PsECeNj3/fxPo6sUunNgrYTU+5IKXej4DNQqk1PTIDSQPhkFEYhzQNrE+v9Aeibm60DajDtDIG4Bq9zARCDuAQNutViCTgH0VhI1Mwme03W3Oc8fQLfyJw4DGyB1VoUjTbYWSsXhA0A/WK9KangE6AXretnbNwr0AM/LZt9EzNZGLxodjzl1xNf5sSav82fyh5qeIoiyzpJ/OH94ZEk/UdxfADJgObO1Aw6wBlJ7T1fHj8Zs6dPVoXyTH5m6MwH8BalrgS6MxbOl7jCFRuHho/CROOTI0keAoUYZDw+NRw6Fj8LgETL73UpNIcGSHC/xeYnB42/qKCQOR8jmWehtOUj7qf3Gfmxftq/Zry9m6j3tzII57rmLF95RQGFavs1sc6bY36XGIBpNBcVca6cwMWliurJ/MdN2chcvvFPn8x8TW6pEpz5mUITMYvCYR6EJUQwmuv3o9hT67plb69q9Houbxx523z2z7K5q32ylWlst/27XJc8r8afYJEbFgNiBFHvEXrFbDIsBsVOMtU5M4ONxEoUhpIjG5xRy2f9bqiV+awCkc8pXxnOlk8vKgqmVPa0ST/QX6d+MyalpGdN0HW6EsHZrW/vgYAHWmsW2Fh2EXW+h40Fb68nA6ktwc5tbN/NNa8u6D5H6JwIYqgWnjFepRnKzbW+Xg0GglRz13f5eWdRaGq9S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VhaqqAACWZVlKKQwGw0B1dfV5AAgEAutAt2UcDAZRUVGx+j09PX18Zmbmg1wu1yyK4qoGWJYFwzAhrVY7RCm9vnv37kmHw9FLCMkCgCAIYFl2XW5mi0Mera2tq6Acx3nC4fDXU1NTxwBAlmWwLBs3GAwhlmU7M5nM5cOHD0cIIdLaPGNjY9Tlcilr1bwl40gkQoqLi9XlwKp4PP4RIeTM8vr5jUbjWH5+/g+lpaW/EkL4NXEv+f3+g4uLi2U2my3t9Xp/IoQIW1VzHeO5uTlis9lUjuOq4vH4Z6IoHmMYZpQQ8mFxcfHdkpKSHkKIuDbm1q1b9clk8mJPT0+NLMv2bDaLTCbzB4BfAOwM2Gazqel0Ok8QhFcopdd4nv/E7XZPbwwSRdHQ19f3Nsdx56ampg7KsqxfEVleXl5mz5497xNCFp+mnydKHYvFSGFhobrFeW3p7+9/M51OX8pkMqUralYURQFA9Xo9bDbb6YaGhm/dbjd8Ph+Kioq2B15YWIDJZNpsP7M+n+8Cz/NnBEEolyQJlFKoqgpK6Yqqx3Q63RdNTU1tO7l0nmDc1dVFGhoa1GVAY1dX13vz8/MXRFEsWwFavoGiOp2uW6/XX1dVtdflcnFOp5MDgM7OTmi1WjQ2Nm4NHAgEUFVVheHhYRIOh8mpU6cUALh582ZrNBr9kuf5XQzDgBAyYzQapzUazc9VVVUD+/fv/32zhN3d3fB6vdsz5jgOVqt11XDjxo13U6nURUpphSRJI3l5eX0ajab76NGjd61W68PNkrS3t8PtduPAgQM7bibI0NAQ3G43gsFgUywWuygIgqooym9arbbD6/VOEkJWr7qysjLS1tZG7Xa74nQ61efuEkOhUOHExMSJ/v5+22bz0Wj0xffAoVBoU3tBQcFTm/LnHQQAHj16BEVRiKIoqsvl+k9eGn8BMMeiAFTierUAAAAASUVORK5CYII=" alt="" /></span>
|
||||
<strong>Propel</strong>
|
||||
<span class="count">
|
||||
<span>{{ collector.querycount }}</span>
|
||||
<span>{{ '%0.0f'|format(collector.time * 1000) }} ms</span>
|
||||
</span>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -42,7 +48,7 @@
|
|||
color: #464646;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.SQLInfo, .SQLComment {
|
||||
.SQLComment {
|
||||
color: gray;
|
||||
display: block;
|
||||
font-size: 0.9em;
|
||||
|
@ -60,94 +66,80 @@
|
|||
padding: 8px 35px 8px 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#content .SQLExplain h2 {
|
||||
font-size: 17px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.query-trace {
|
||||
display: none;
|
||||
overflow: auto;
|
||||
padding: 5px;
|
||||
border: 1px solid silver;
|
||||
margin: 5px;
|
||||
border-radius: 5px;
|
||||
font-family: monospace;
|
||||
white-space: nowrap;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.query-trace .gray {
|
||||
color: silver;
|
||||
}
|
||||
|
||||
.query-trace .gray + .regular {
|
||||
margin-top: 3px;
|
||||
}
|
||||
.query-trace .regular + .gray {
|
||||
margin-top: 3px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
function toggle(id) {
|
||||
var el = document.getElementById(id);
|
||||
el.style.display = el.style.display === 'block' ? 'none' : 'block';
|
||||
}
|
||||
</script>
|
||||
<h2>Query Metrics</h2>
|
||||
|
||||
<h2>Queries</h2>
|
||||
<table summary="Show logged queries">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>SQL queries</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% if not collector.querycount %}
|
||||
<tr><td>No queries.</td></tr>
|
||||
{% else %}
|
||||
{% for i, query in collector.queries %}
|
||||
<tr>
|
||||
<td>
|
||||
<a name="propel-query-{{ i }}" ></a>
|
||||
<code>{{ query.sql|format_sql|raw }}</code>
|
||||
{% if app.request.query.has('query') and app.request.query.get('query') == i %}
|
||||
<div class="SQLExplain">
|
||||
{{ render(controller('PropelBundle:Panel:explain', {
|
||||
'token': token,
|
||||
'panel': 'propel',
|
||||
'query': app.request.query.get('query'),
|
||||
'connection': app.request.query.get('connection')
|
||||
})) }}
|
||||
{% if not collector.querycount %}
|
||||
<div class="empty">
|
||||
<p>No database queries were performed.</p>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="metrics">
|
||||
<div class="metric">
|
||||
<span class="value">{{ collector.querycount }}</span>
|
||||
<span class="label">Database Queries</span>
|
||||
</div>
|
||||
|
||||
<div class="metric">
|
||||
<span class="value">{{ '%0.2f'|format(collector.time * 1000) }} <span class="unit">ms</span></span>
|
||||
<span class="label">Query time</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2>Queries</h2>
|
||||
<table summary="Show logged queries">
|
||||
<thead>
|
||||
<tr>
|
||||
<th nowrap>#</th>
|
||||
<th nowrap>Time</th>
|
||||
<th nowrap>Memory</th>
|
||||
<th style="width: 100%;">Query</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="queries">
|
||||
{% for i, query in collector.queries %}
|
||||
<tr>
|
||||
<td class="font-normal text-small" nowrap>{{ loop.index }}</td>
|
||||
<td class="font-normal text-small" nowrap>{{ '%0.2f'|format(query.time * 1000) }} ms</td>
|
||||
<td class="font-normal text-small" nowrap>{{ query.memory|format_memory }}</td>
|
||||
<td>
|
||||
<a name="propel-query-{{ i }}" ></a>
|
||||
<code>{{ query.sql|format_sql|raw }}</code>
|
||||
<div class="metadata font-normal text-muted">
|
||||
<span class="text-small">
|
||||
Connection: {{ query.connection }}
|
||||
</span>
|
||||
-
|
||||
<a class="btn btn-link text-small sf-toggle" data-toggle-selector="#propel-stack-trace-{{ i }}" data-toggle-alt-content="Hide trace">Show trace</a>
|
||||
-
|
||||
{% if app.request.query.get('query', -1) == i %}
|
||||
<a class="btn btn-link text-small" href="{{ path('_profiler', {'panel': 'propel', 'token': token, 'connection': query.connection}) }}}#propel-query-{{ i }}">Hide query explanation</a>
|
||||
{% else %}
|
||||
<a class="btn btn-link text-small" href="{{ path('_profiler', {'panel': 'propel', 'token': token, 'connection': query.connection, 'query': i}) }}#propel-query-{{ i }}">Explain query</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="SQLInfo">
|
||||
Time: {{ query.time }} - Memory: {{ query.memory|format_memory }} - Connection: {{ query.connection }} -
|
||||
<a href="#" onclick="toggle('propel-stack-trace-{{ i }}'); return false;">Stacktrace</a>
|
||||
|
||||
{% if app.request.query.get('query', -1) != i %}
|
||||
- <a href="{{ path('_profiler', {'panel': 'propel', 'token': token, 'connection': query.connection, 'query': i}) }}#propel-query-{{ i }}">Explain the query</a>
|
||||
{% if app.request.query.has('query') and app.request.query.get('query') == i %}
|
||||
<div class="SQLExplain">
|
||||
{{ render(controller('PropelBundle:Panel:explain', {
|
||||
'token': token,
|
||||
'panel': 'propel',
|
||||
'query': app.request.query.get('query'),
|
||||
'connection': app.request.query.get('connection')
|
||||
})) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div id="propel-stack-trace-{{ i }}" class="query-trace">
|
||||
{% for trace in query.stackTrace %}
|
||||
<div class="{{
|
||||
(': Symfony\\Component' in trace
|
||||
or ': Propel\\Runtime' in trace
|
||||
or ': Propel\\Bundle\\PropelBundle' in trace
|
||||
or ': call_user_func(Object(Symfony\\Component' in trace
|
||||
or ': call_user_func(Array, Object(Symfony\\Component' in trace
|
||||
) ? 'gray' : 'regular' }}">{{ trace }}</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="propel-stack-trace-{{ i }}" class="sf-toggle-content sf-toggle-hidden">
|
||||
{{ profiler_dump(query.trace, maxDepth=1) }}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{{ render(controller('PropelBundle:Panel:configuration')) }}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<h2>Explanation</h2>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
{% for label in data[0]|keys %}
|
||||
|
|
|
@ -17,10 +17,25 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
|||
class SchemaLocator
|
||||
{
|
||||
protected $fileLocator;
|
||||
protected $configuration;
|
||||
|
||||
public function __construct(FileLocatorInterface $fileLocator)
|
||||
public function __construct(FileLocatorInterface $fileLocator, array $configuration)
|
||||
{
|
||||
$this->fileLocator = $fileLocator;
|
||||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
public function locateFromBundlesAndConfiguration(array $bundles)
|
||||
{
|
||||
$schemas = $this->locateFromBundles($bundles);
|
||||
|
||||
$path = $this->configuration['paths']['schemaDir'].'/schema.xml';
|
||||
if (file_exists($path)) {
|
||||
$schema = new \SplFileInfo($path);
|
||||
$schemas[(string) $schema] = array(null, $schema);
|
||||
}
|
||||
|
||||
return $schemas;
|
||||
}
|
||||
|
||||
public function locateFromBundles(array $bundles)
|
||||
|
@ -70,6 +85,6 @@ class SchemaLocator
|
|||
$schema->getRealPath()
|
||||
);
|
||||
|
||||
return sprintf('@%s/Resources/config/%s', $bundle->getName(), $schemaPath);
|
||||
return sprintf('%s/Resources/config/%s', $bundle->getName(), $schemaPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,17 +51,11 @@ class YamlDataDumperTest extends TestCase
|
|||
id: '1'
|
||||
name: 'An important one'
|
||||
author_id: CoolBookAuthor_1
|
||||
complementary_infos: !php/object:O:8:"stdClass":1:{s:15:"first_word_date";s:10:"2012-01-01";}
|
||||
complementary_infos: !php/object 'O:8:"stdClass":1:{s:15:"first_word_date";s:10:"2012-01-01";}'
|
||||
|
||||
YAML;
|
||||
|
||||
$result = file_get_contents($filename);
|
||||
|
||||
//yaml changed the way objects are serialized in
|
||||
// -> https://github.com/symfony/yaml/commit/d5a7902da7e5af069bb8fdcfcf029a229deb1111
|
||||
//so we need to replace old behavior with new, to get this test working in all versions
|
||||
$result = str_replace(' !!php/object', ' !php/object', $result);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
||||
|
|
17
Tests/Fixtures/FakeBundle/FakeBundle.php
Normal file
17
Tests/Fixtures/FakeBundle/FakeBundle.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: drewbrown
|
||||
* Date: 2/2/18
|
||||
* Time: 3:32 PM
|
||||
*/
|
||||
|
||||
namespace Propel\Bundle\PropelBundle\Tests\Fixtures\FakeBundle;
|
||||
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class FakeBundle extends Bundle
|
||||
{
|
||||
|
||||
}
|
|
@ -39,13 +39,13 @@ class EntryQueryTest extends AclTestCase
|
|||
|
||||
public function testFindByAclIdentityInvalidSecurityIdentity()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
EntryQuery::create()->findByAclIdentity($this->getAclObjectIdentity(), array('foo'), $this->con);
|
||||
}
|
||||
|
||||
public function testFindByAclIdentityInvalidSecurityIdentityObject()
|
||||
{
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
EntryQuery::create()->findByAclIdentity($this->getAclObjectIdentity(), array(new \stdClass()), $this->con);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,10 @@ class EntryTest extends AclTestCase
|
|||
{
|
||||
public function testToAclEntry()
|
||||
{
|
||||
$acl = $this->getMock('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl', array(), array(), '', false, false);
|
||||
$acl = $this->getMockBuilder('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$entry = $this->createModelEntry();
|
||||
|
||||
$aclEntry = ModelEntry::toAclEntry($entry, $acl);
|
||||
|
@ -45,7 +48,9 @@ class EntryTest extends AclTestCase
|
|||
*/
|
||||
public function testToAclEntryFieldEntry()
|
||||
{
|
||||
$acl = $this->getMock('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl', array(), array(), '', false, false);
|
||||
$acl = $this->getMockBuilder('Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$entry = $this->createModelEntry();
|
||||
$entry->setFieldName('name');
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class ObjectIdentityQueryTest extends AclTestCase
|
|||
$result = ObjectIdentityQuery::create()->findChildren($objIdentity, $this->con);
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertInstanceOf('Propel\Bundle\PropelBundle\Model\Acl\ObjectIdentity', $result->getFirst());
|
||||
$this->assertSame($childObjIdentity, $result->getFirst());
|
||||
$this->assertEquals($childObjIdentity, $result->getFirst());
|
||||
$this->assertSame($objIdentity, $result->getFirst()->getObjectIdentityRelatedByParentObjectIdentityId());
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class SecurityIdentityTest extends AclTestCase
|
|||
$identity->setIdentifier('invalidIdentifier');
|
||||
$identity->setUsername(true);
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
SecurityIdentity::toAclIdentity($identity);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class SecurityIdentityTest extends AclTestCase
|
|||
$identity->setIdentifier('invalidIdentifier');
|
||||
$identity->setUsername(false);
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
SecurityIdentity::toAclIdentity($identity);
|
||||
}
|
||||
|
||||
|
@ -84,9 +84,9 @@ class SecurityIdentityTest extends AclTestCase
|
|||
|
||||
public function testFromAclIdentityWithInvalid()
|
||||
{
|
||||
$secIdentity = $this->getMock('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface');
|
||||
$secIdentity = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\SecurityIdentityInterface')->getMock();
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
SecurityIdentity::fromAclIdentity($secIdentity, $this->con);
|
||||
}
|
||||
|
||||
|
|
|
@ -290,12 +290,17 @@ class PropelParamConverterTest extends TestCase
|
|||
$this->assertEquals($nb + 1, $this->con->getQueryCount(), 'no new query to get the books');
|
||||
}
|
||||
|
||||
public function testConfigurationReadFromRouteOptionsIfEmpty()
|
||||
public function testConfigurationReadFromRequestAttributesIfEmpty()
|
||||
{
|
||||
$this->loadFixtures();
|
||||
|
||||
$routes = new RouteCollection();
|
||||
$routes->add('test_route', new Route('/test/{authorId}', array(), array(), array(
|
||||
$paramConverter = new PropelParamConverter();
|
||||
|
||||
$request = new Request();
|
||||
$request->attributes->add(array(
|
||||
'_route' => 'test_route',
|
||||
'id' => 10,
|
||||
'author' => null,
|
||||
'propel_converter' => array(
|
||||
'author' => array(
|
||||
'mapping' => array(
|
||||
|
@ -303,23 +308,6 @@ class PropelParamConverterTest extends TestCase
|
|||
),
|
||||
),
|
||||
),
|
||||
)));
|
||||
|
||||
$router = $this->getMock('Symfony\Bundle\FrameworkBundle\Routing\Router', array(), array(), '', false);
|
||||
$router
|
||||
->expects($this->once())
|
||||
->method('getRouteCollection')
|
||||
->will($this->returnValue($routes))
|
||||
;
|
||||
|
||||
$paramConverter = new PropelParamConverter();
|
||||
$paramConverter->setRouter($router);
|
||||
|
||||
$request = new Request();
|
||||
$request->attributes->add(array(
|
||||
'_route' => 'test_route',
|
||||
'id' => 10,
|
||||
'author' => null,
|
||||
));
|
||||
|
||||
$configuration = new ParamConverter(array(
|
||||
|
|
|
@ -33,7 +33,7 @@ class AclProviderTest extends AclTestCase
|
|||
{
|
||||
$provider = $this->getAclProvider();
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Security\Acl\Exception\AclNotFoundException', 'There is no ACL available for this object identity. Please create one using the MutableAclProvider.');
|
||||
$this->expectException('Symfony\Component\Security\Acl\Exception\AclNotFoundException', 'There is no ACL available for this object identity. Please create one using the MutableAclProvider.');
|
||||
$provider->findAcl($this->getAclObjectIdentity());
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class AclProviderTest extends AclTestCase
|
|||
{
|
||||
$provider = $this->getAclProvider();
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Security\Acl\Exception\AclNotFoundException', 'There is at least no ACL for this object identity and the given security identities. Try retrieving the ACL without security identity filter and add ACEs for the security identities.');
|
||||
$this->expectException('Symfony\Component\Security\Acl\Exception\AclNotFoundException', 'There is at least no ACL for this object identity and the given security identities. Try retrieving the ACL without security identity filter and add ACEs for the security identities.');
|
||||
$provider->findAcl($this->getAclObjectIdentity(), array($this->getRoleSecurityIdentity()));
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ class AclProviderTest extends AclTestCase
|
|||
|
||||
$this->assertTrue($acl->isGranted(array(1, 2, 4, 8, 16, 32, 64), array($this->getRoleSecurityIdentity('ROLE_USER'))));
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Security\Acl\Exception\NoAceFoundException');
|
||||
$this->expectException('Symfony\Component\Security\Acl\Exception\NoAceFoundException');
|
||||
$acl->isGranted(array(128), array($this->getRoleSecurityIdentity('ROLE_USER')));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class AclTest extends AclTestCase
|
|||
$collection = new ObjectCollection();
|
||||
$collection->setModel('Propel\Bundle\PropelBundle\Model\Acl\AclClass');
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Security\Acl\Exception\Exception');
|
||||
$this->expectException('Symfony\Component\Security\Acl\Exception\Exception');
|
||||
new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class AclTest extends AclTestCase
|
|||
$aclObj = $this->getAclObjectIdentity();
|
||||
$acl = new Acl($collection, $aclObj, new PermissionGrantingStrategy());
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$acl->isSidLoaded('foo');
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ class AclTest extends AclTestCase
|
|||
|
||||
$acl = new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Security\Acl\Exception\NoAceFoundException');
|
||||
$this->expectException('Symfony\Component\Security\Acl\Exception\NoAceFoundException');
|
||||
$acl->isGranted(array(64), array($this->getRoleSecurityIdentity()));
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ class AclTest extends AclTestCase
|
|||
|
||||
$acl = new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Security\Acl\Exception\NoAceFoundException');
|
||||
$this->expectException('Symfony\Component\Security\Acl\Exception\NoAceFoundException');
|
||||
$acl->isGranted(array(64), array($this->getRoleSecurityIdentity('ROLE_USER')));
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ class AclTest extends AclTestCase
|
|||
|
||||
$acl = new Acl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Security\Acl\Exception\NoAceFoundException');
|
||||
$this->expectException('Symfony\Component\Security\Acl\Exception\NoAceFoundException');
|
||||
$acl->isFieldGranted('name', array(64), array($this->getRoleSecurityIdentity()));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class AuditableAclTest extends AclTestCase
|
|||
|
||||
$acl = new AuditableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
|
||||
|
||||
$this->setExpectedException('OutOfBoundsException');
|
||||
$this->expectException('OutOfBoundsException');
|
||||
$acl->updateObjectAuditing(0, false, false);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class AuditableAclTest extends AclTestCase
|
|||
$collection->append($entry);
|
||||
$acl = new AuditableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$acl->updateObjectFieldAuditing(0, 'foo', false, false);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class AuditableAclTest extends AclTestCase
|
|||
$collection->append($entry);
|
||||
$acl = new AuditableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy());
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$acl->updateObjectAuditing(0, 'foo', 'bar');
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class MutableAclTest extends AclTestCase
|
|||
$collection = new ObjectCollection();
|
||||
$collection->setModel('Propel\Bundle\PropelBundle\Model\Acl\AclClass');
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Security\Acl\Exception\Exception');
|
||||
$this->expectException('Symfony\Component\Security\Acl\Exception\Exception');
|
||||
new MutableAcl($collection, $this->getAclObjectIdentity(), new PermissionGrantingStrategy(), array(), null, false, $this->con);
|
||||
}
|
||||
|
||||
|
@ -68,14 +68,14 @@ class MutableAclTest extends AclTestCase
|
|||
public function testInsertAceInvalidMask()
|
||||
{
|
||||
$acl = $this->createEmptyAcl();
|
||||
$this->setExpectedException('InvalidArgumentException', 'The given mask is not valid. Please provide an integer.');
|
||||
$this->expectException('InvalidArgumentException', 'The given mask is not valid. Please provide an integer.');
|
||||
$acl->insertClassAce($this->getRoleSecurityIdentity(), 'foo');
|
||||
}
|
||||
|
||||
public function testInsertAceOutofBounds()
|
||||
{
|
||||
$acl = $this->createEmptyAcl();
|
||||
$this->setExpectedException('OutOfBoundsException', 'The index must be in the interval [0, 0].');
|
||||
$this->expectException('OutOfBoundsException', 'The index must be in the interval [0, 0].');
|
||||
$acl->insertClassAce($this->getRoleSecurityIdentity(), 64, 1);
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ class MutableAclTest extends AclTestCase
|
|||
public function testUpdateAceInvalidIndex()
|
||||
{
|
||||
$acl = $this->createEmptyAcl();
|
||||
$this->setExpectedException('OutOfBoundsException');
|
||||
$this->expectException('OutOfBoundsException');
|
||||
$acl->updateClassAce(0, 64);
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ class MutableAclTest extends AclTestCase
|
|||
$acl = $this->createEmptyAcl();
|
||||
$acl->insertClassAce($this->getRoleSecurityIdentity(), 64);
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException', 'The given field "name" does not exist.');
|
||||
$this->expectException('InvalidArgumentException', 'The given field "name" does not exist.');
|
||||
$acl->updateClassFieldAce(0, 'name', 128);
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class MutableAclProviderTest extends AclTestCase
|
|||
$acl->insertObjectAce($this->getRoleSecurityIdentity(), 64);
|
||||
$this->getAclProvider()->updateAcl($acl);
|
||||
|
||||
$this->setExpectedException('Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException');
|
||||
$this->expectException('Symfony\Component\Security\Acl\Exception\AclAlreadyExistsException');
|
||||
$this->getAclProvider()->createAcl($this->getAclObjectIdentity(1));
|
||||
}
|
||||
|
||||
|
@ -109,9 +109,9 @@ class MutableAclProviderTest extends AclTestCase
|
|||
|
||||
public function testUpdateAclInvalidAcl()
|
||||
{
|
||||
$acl = $this->getMock('Symfony\Component\Security\Acl\Model\MutableAclInterface');
|
||||
$acl = $this->getMockBuilder('Symfony\Component\Security\Acl\Model\MutableAclInterface')->getMock();
|
||||
|
||||
$this->setExpectedException('InvalidArgumentException');
|
||||
$this->expectException('InvalidArgumentException');
|
||||
$this->getAclProvider()->updateAcl($acl);
|
||||
}
|
||||
|
||||
|
|
97
Tests/Service/SchemaLocatorTest.php
Normal file
97
Tests/Service/SchemaLocatorTest.php
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?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\Bundle\PropelBundle\Tests\Service;
|
||||
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamDirectory;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Propel\Bundle\PropelBundle\Service\SchemaLocator;
|
||||
use Propel\Bundle\PropelBundle\Tests\Fixtures\FakeBundle\FakeBundle;
|
||||
use Propel\Bundle\PropelBundle\Tests\TestCase;
|
||||
use Propel\Common\Config\FileLocator;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
class SchemaLocatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Kernel
|
||||
*/
|
||||
private $kernelMock;
|
||||
|
||||
/**
|
||||
* @var vfsStreamDirectory
|
||||
*/
|
||||
private $root;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
private $fileLocator;
|
||||
|
||||
/**
|
||||
* @var MockObject
|
||||
*/
|
||||
private $bundleMock;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$pathStructure = [
|
||||
'configuration' => [
|
||||
'directory' => [
|
||||
'schema.xml' => 'Schema from configuration'
|
||||
]
|
||||
],
|
||||
];
|
||||
$this->root = vfsStream::setup('projectDir');
|
||||
vfsStream::create($pathStructure);
|
||||
|
||||
$this->kernelMock = $this->getMockBuilder(Kernel::class)->disableOriginalConstructor()-> getMock();
|
||||
$this->kernelMock->method('getProjectDir')->willReturn($this->root->url());
|
||||
|
||||
$this->bundleMock = new FakeBundle();
|
||||
|
||||
$this->configuration['paths']['schemaDir'] = vfsStream::url('projectDir/configuration/directory');
|
||||
$this->fileLocator = new FileLocator(
|
||||
[
|
||||
__DIR__ . '/../Fixtures',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function testLocateFromBundle()
|
||||
{
|
||||
|
||||
$locator = new SchemaLocator($this->fileLocator, $this->configuration);
|
||||
$files = $locator->locateFromBundle($this->bundleMock);
|
||||
|
||||
$this->assertCount(1, $files);
|
||||
$this->assertTrue(isset($files[__DIR__ . '/../Fixtures/FakeBundle/Resources/config/bundle.schema.xml']));
|
||||
$this->assertEquals('bundle.schema.xml', $files[__DIR__ . '/../Fixtures/FakeBundle/Resources/config/bundle.schema.xml'][1]->getFileName());
|
||||
|
||||
}
|
||||
|
||||
public function testLocateFromBundlesAndConfiguration()
|
||||
{
|
||||
$locator = new SchemaLocator($this->fileLocator, $this->configuration);
|
||||
$files = $locator->locateFromBundlesAndConfiguration(
|
||||
[$this->bundleMock]
|
||||
);
|
||||
|
||||
$this->assertCount(2, $files);
|
||||
$this->assertTrue(isset($files[__DIR__ . '/../Fixtures/FakeBundle/Resources/config/bundle.schema.xml']));
|
||||
$this->assertEquals('bundle.schema.xml', $files[__DIR__ . '/../Fixtures/FakeBundle/Resources/config/bundle.schema.xml'][1]->getFileName());
|
||||
$this->assertTrue(isset($files['vfs://projectDir/configuration/directory/schema.xml']));
|
||||
$this->assertEquals('schema.xml', $files['vfs://projectDir/configuration/directory/schema.xml'][1]->getFileName());
|
||||
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
namespace Propel\Bundle\PropelBundle\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase as BaseTestCase;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
@ -17,7 +18,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|||
/**
|
||||
* TestCase
|
||||
*/
|
||||
class TestCase extends \PHPUnit_Framework_TestCase
|
||||
class TestCase extends BaseTestCase
|
||||
{
|
||||
public function getContainer()
|
||||
{
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
if(!class_exists('Symfony\\Component\\Form\\Test\\TypeTestCase')) {
|
||||
class_alias('Symfony\\Component\\Form\\Tests\\Extension\\Core\\Type\\TypeTestCase', 'Symfony\\Component\\Form\\Test\\TypeTestCase');
|
||||
}
|
|
@ -51,7 +51,7 @@ class SyntaxExtension extends \Twig_Extension
|
|||
$absBytes /= 1024;
|
||||
}
|
||||
|
||||
return self::toPrecision($sign * $absBytes, $precision) . $suffix[$i];
|
||||
return self::toPrecision($sign * $absBytes, $precision).' '.$suffix[$i];
|
||||
}
|
||||
|
||||
public function formatSQL($sql)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "propel/propel-bundle",
|
||||
"description": "Integration of Propel in Symfony2",
|
||||
"name": "deblan/propel-bundle",
|
||||
"description": "Integration of Propel in Symfony",
|
||||
"keywords": ["propel", "orm", "persistence"],
|
||||
"type": "symfony-bundle",
|
||||
"license": "MIT",
|
||||
|
@ -8,20 +8,22 @@
|
|||
"name": "William Durand",
|
||||
"email": "william.durand1@gmail.com"
|
||||
}],
|
||||
|
||||
"autoload": {
|
||||
"psr-4": { "Propel\\Bundle\\PropelBundle\\": "" },
|
||||
"exclude-from-classmap": [ "Tests/" ]
|
||||
},
|
||||
|
||||
"require": {
|
||||
"propel/propel": "2.0.0-alpha6",
|
||||
"symfony/symfony": "^2.8|^3.0",
|
||||
"symfony/security-acl": "^2.8|^3.0"
|
||||
"propel/propel": "dev-master",
|
||||
"symfony/console": "^2.8|^3.0|^4.0",
|
||||
"symfony/dependency-injection": "^2.8|^3.0|^4.0",
|
||||
"symfony/framework-bundle": "^2.8|^3.0|^4.0",
|
||||
"symfony/security-acl": "^2.8|^3.0|^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.21|^5.0.10",
|
||||
"sensio/framework-extra-bundle": "^3.0.2",
|
||||
"fzaninotto/faker": "^1.5"
|
||||
"phpunit/phpunit": "^6.0",
|
||||
"sensio/framework-extra-bundle": "^4.0",
|
||||
"symfony/form": "^2.8|^3.0|^4.0",
|
||||
"fzaninotto/faker": "^1.5",
|
||||
"mikey179/vfsStream": "^1.6"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
syntaxCheck="false"
|
||||
bootstrap="./Tests/bootstrap.php">
|
||||
bootstrap="vendor/autoload.php">
|
||||
<php>
|
||||
<!-- <server name="SYMFONY" value="/path/to/symfony" /> -->
|
||||
</php>
|
||||
|
|
Loading…
Reference in a new issue