Merge branch '2.6' into 2.7
* 2.6: [Bridge] [Propel] minor improvements to the Propel bridge. [FrameworkBundle] Allow custom services for validator mapping cache.
This commit is contained in:
commit
94b293c5e3
@ -26,7 +26,7 @@ class PropelDataCollector extends DataCollector
|
|||||||
/**
|
/**
|
||||||
* Propel logger.
|
* Propel logger.
|
||||||
*
|
*
|
||||||
* @var \Symfony\Bridge\Propel1\Logger\PropelLogger
|
* @var PropelLogger
|
||||||
*/
|
*/
|
||||||
private $logger;
|
private $logger;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class PropelDataCollector extends DataCollector
|
|||||||
/**
|
/**
|
||||||
* Returns the collector name.
|
* Returns the collector name.
|
||||||
*
|
*
|
||||||
* @return string The collector name.
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
@ -71,9 +71,9 @@ class PropelDataCollector extends DataCollector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns queries.
|
* Returns the collected stats for all executed SQL queries.
|
||||||
*
|
*
|
||||||
* @return array Queries
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getQueries()
|
public function getQueries()
|
||||||
{
|
{
|
||||||
@ -83,7 +83,7 @@ class PropelDataCollector extends DataCollector
|
|||||||
/**
|
/**
|
||||||
* Returns the query count.
|
* Returns the query count.
|
||||||
*
|
*
|
||||||
* @return int The query count
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getQueryCount()
|
public function getQueryCount()
|
||||||
{
|
{
|
||||||
@ -91,9 +91,9 @@ class PropelDataCollector extends DataCollector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the total time of queries.
|
* Returns the total time spent on running all queries.
|
||||||
*
|
*
|
||||||
* @return float The total time of queries
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function getTime()
|
public function getTime()
|
||||||
{
|
{
|
||||||
@ -106,9 +106,9 @@ class PropelDataCollector extends DataCollector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array of Build objects.
|
* Computes the stats of all executed SQL queries.
|
||||||
*
|
*
|
||||||
* @return array An array of Build objects
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function buildQueries()
|
private function buildQueries()
|
||||||
{
|
{
|
||||||
@ -136,9 +136,9 @@ class PropelDataCollector extends DataCollector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count queries.
|
* Returns the total count of SQL queries.
|
||||||
*
|
*
|
||||||
* @return int The number of queries.
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function countQueries()
|
private function countQueries()
|
||||||
{
|
{
|
||||||
|
@ -26,6 +26,12 @@ class PropelFactory implements UserProviderFactoryInterface
|
|||||||
private $key;
|
private $key;
|
||||||
private $providerId;
|
private $providerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string $key
|
||||||
|
* @param string $providerId
|
||||||
|
*/
|
||||||
public function __construct($key, $providerId)
|
public function __construct($key, $providerId)
|
||||||
{
|
{
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
@ -50,8 +56,13 @@ class PropelFactory implements UserProviderFactoryInterface
|
|||||||
{
|
{
|
||||||
$node
|
$node
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('class')->isRequired()->cannotBeEmpty()->end()
|
->scalarNode('class')
|
||||||
->scalarNode('property')->defaultNull()->end()
|
->isRequired()
|
||||||
|
->cannotBeEmpty()
|
||||||
|
->end()
|
||||||
|
->scalarNode('property')
|
||||||
|
->defaultNull()
|
||||||
|
->end()
|
||||||
->end()
|
->end()
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,19 @@ class ModelType extends AbstractType
|
|||||||
*/
|
*/
|
||||||
private $propertyAccessor;
|
private $propertyAccessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param PropertyAccessorInterface|null $propertyAccessor
|
||||||
|
*/
|
||||||
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
|
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
|
||||||
{
|
{
|
||||||
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
|
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
if ($options['multiple']) {
|
if ($options['multiple']) {
|
||||||
@ -67,6 +75,9 @@ class ModelType extends AbstractType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||||
{
|
{
|
||||||
$propertyAccessor = $this->propertyAccessor;
|
$propertyAccessor = $this->propertyAccessor;
|
||||||
@ -99,11 +110,17 @@ class ModelType extends AbstractType
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'choice';
|
return 'choice';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
return 'model';
|
return 'model';
|
||||||
|
@ -40,6 +40,9 @@ class TranslationCollectionType extends AbstractType
|
|||||||
$builder->addEventSubscriber($listener);
|
$builder->addEventSubscriber($listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
public function getParent()
|
public function getParent()
|
||||||
{
|
{
|
||||||
return 'collection';
|
return 'collection';
|
||||||
|
@ -85,6 +85,7 @@ class PropelDataCollectorTest extends Propel1TestCase
|
|||||||
private function createCollector($queries)
|
private function createCollector($queries)
|
||||||
{
|
{
|
||||||
$config = $this->getMock('\PropelConfiguration');
|
$config = $this->getMock('\PropelConfiguration');
|
||||||
|
|
||||||
$config
|
$config
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('getParameter')
|
->method('getParameter')
|
||||||
|
@ -14,8 +14,7 @@ namespace Symfony\Bridge\Propel1\Tests\Fixtures;
|
|||||||
class Column extends \ColumnMap
|
class Column extends \ColumnMap
|
||||||
{
|
{
|
||||||
private $name;
|
private $name;
|
||||||
|
private $type;
|
||||||
protected $type;
|
|
||||||
|
|
||||||
public function __construct($name, $type)
|
public function __construct($name, $type)
|
||||||
{
|
{
|
||||||
@ -55,6 +54,6 @@ class Column extends \ColumnMap
|
|||||||
|
|
||||||
public function isNotNull()
|
public function isNotNull()
|
||||||
{
|
{
|
||||||
return ('id' === $this->name);
|
return 'id' === $this->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,11 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
|
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
|
||||||
|
|
||||||
use PropelPDO;
|
|
||||||
|
|
||||||
class Item implements \Persistent
|
class Item implements \Persistent
|
||||||
{
|
{
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
private $value;
|
private $value;
|
||||||
|
|
||||||
private $groupName;
|
private $groupName;
|
||||||
|
|
||||||
private $price;
|
private $price;
|
||||||
|
|
||||||
private $slug;
|
private $slug;
|
||||||
@ -106,11 +101,11 @@ class Item implements \Persistent
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(PropelPDO $con = null)
|
public function delete(\PropelPDO $con = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(PropelPDO $con = null)
|
public function save(\PropelPDO $con = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,16 +11,11 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
|
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
|
||||||
|
|
||||||
use PropelPDO;
|
|
||||||
|
|
||||||
class TranslatableItem implements \Persistent
|
class TranslatableItem implements \Persistent
|
||||||
{
|
{
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
private $currentTranslations;
|
private $currentTranslations;
|
||||||
|
|
||||||
private $groupName;
|
private $groupName;
|
||||||
|
|
||||||
private $price;
|
private $price;
|
||||||
|
|
||||||
public function __construct($id = null, $translations = array())
|
public function __construct($id = null, $translations = array())
|
||||||
@ -91,15 +86,15 @@ class TranslatableItem implements \Persistent
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(PropelPDO $con = null)
|
public function delete(\PropelPDO $con = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(PropelPDO $con = null)
|
public function save(\PropelPDO $con = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTranslation($locale = 'de', PropelPDO $con = null)
|
public function getTranslation($locale = 'de', \PropelPDO $con = null)
|
||||||
{
|
{
|
||||||
if (!isset($this->currentTranslations[$locale])) {
|
if (!isset($this->currentTranslations[$locale])) {
|
||||||
$translation = new TranslatableItemI18n();
|
$translation = new TranslatableItemI18n();
|
||||||
|
@ -11,18 +11,12 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
|
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
|
||||||
|
|
||||||
use PropelPDO;
|
|
||||||
|
|
||||||
class TranslatableItemI18n implements \Persistent
|
class TranslatableItemI18n implements \Persistent
|
||||||
{
|
{
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
private $locale;
|
private $locale;
|
||||||
|
|
||||||
private $value;
|
private $value;
|
||||||
|
|
||||||
private $value2;
|
private $value2;
|
||||||
|
|
||||||
private $item;
|
private $item;
|
||||||
|
|
||||||
public function __construct($id = null, $locale = null, $value = null)
|
public function __construct($id = null, $locale = null, $value = null)
|
||||||
@ -84,11 +78,11 @@ class TranslatableItemI18n implements \Persistent
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(PropelPDO $con = null)
|
public function delete(\PropelPDO $con = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(PropelPDO $con = null)
|
public function save(\PropelPDO $con = null)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ class ModelChoiceListTest extends Propel1TestCase
|
|||||||
*/
|
*/
|
||||||
public function testEmptyClass()
|
public function testEmptyClass()
|
||||||
{
|
{
|
||||||
$choiceList = new ModelChoiceList('');
|
new ModelChoiceList('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,7 +257,7 @@ class ModelChoiceListTest extends Propel1TestCase
|
|||||||
*/
|
*/
|
||||||
public function testInvalidClass()
|
public function testInvalidClass()
|
||||||
{
|
{
|
||||||
$choiceList = new ModelChoiceList('Foo\Bar\DoesNotExistClass');
|
new ModelChoiceList('Foo\Bar\DoesNotExistClass');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCustomIdentifier()
|
public function testCustomIdentifier()
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\Propel1\Tests\Form\DataTransformer;
|
namespace Symfony\Bridge\Propel1\Tests\Form\DataTransformer;
|
||||||
|
|
||||||
use PropelObjectCollection;
|
|
||||||
use Symfony\Bridge\Propel1\Form\DataTransformer\CollectionToArrayTransformer;
|
use Symfony\Bridge\Propel1\Form\DataTransformer\CollectionToArrayTransformer;
|
||||||
use Symfony\Bridge\Propel1\Tests\Propel1TestCase;
|
use Symfony\Bridge\Propel1\Tests\Propel1TestCase;
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
|
|||||||
|
|
||||||
public function testTransform()
|
public function testTransform()
|
||||||
{
|
{
|
||||||
$result = $this->transformer->transform(new PropelObjectCollection());
|
$result = $this->transformer->transform(new \PropelObjectCollection());
|
||||||
|
|
||||||
$this->assertTrue(is_array($result));
|
$this->assertTrue(is_array($result));
|
||||||
$this->assertCount(0, $result);
|
$this->assertCount(0, $result);
|
||||||
@ -50,7 +49,7 @@ class CollectionToArrayTransformerTest extends Propel1TestCase
|
|||||||
|
|
||||||
public function testTransformWithData()
|
public function testTransformWithData()
|
||||||
{
|
{
|
||||||
$coll = new PropelObjectCollection();
|
$coll = new \PropelObjectCollection();
|
||||||
$coll->setData(array('foo', 'bar'));
|
$coll->setData(array('foo', 'bar'));
|
||||||
|
|
||||||
$result = $this->transformer->transform($coll);
|
$result = $this->transformer->transform($coll);
|
||||||
|
@ -18,16 +18,20 @@ use Symfony\Component\Form\Guess\Guess;
|
|||||||
class PropelTypeGuesserTest extends Propel1TestCase
|
class PropelTypeGuesserTest extends Propel1TestCase
|
||||||
{
|
{
|
||||||
const CLASS_NAME = 'Symfony\Bridge\Propel1\Tests\Fixtures\Item';
|
const CLASS_NAME = 'Symfony\Bridge\Propel1\Tests\Fixtures\Item';
|
||||||
|
|
||||||
const UNKNOWN_CLASS_NAME = 'Symfony\Bridge\Propel1\Tests\Fixtures\UnknownItem';
|
const UNKNOWN_CLASS_NAME = 'Symfony\Bridge\Propel1\Tests\Fixtures\UnknownItem';
|
||||||
|
|
||||||
private $guesser;
|
private $guesser;
|
||||||
|
|
||||||
public function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->guesser = new PropelTypeGuesser();
|
$this->guesser = new PropelTypeGuesser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function tearDown()
|
||||||
|
{
|
||||||
|
$this->guesser = null;
|
||||||
|
}
|
||||||
|
|
||||||
public function testGuessMaxLengthWithText()
|
public function testGuessMaxLengthWithText()
|
||||||
{
|
{
|
||||||
$value = $this->guesser->guessMaxLength(self::CLASS_NAME, 'value');
|
$value = $this->guesser->guessMaxLength(self::CLASS_NAME, 'value');
|
||||||
|
@ -23,16 +23,9 @@ class TranslationCollectionTypeTest extends TypeTestCase
|
|||||||
const TRANSLATABLE_I18N_CLASS = 'Symfony\Bridge\Propel1\Tests\Fixtures\TranslatableItemI18n';
|
const TRANSLATABLE_I18N_CLASS = 'Symfony\Bridge\Propel1\Tests\Fixtures\TranslatableItemI18n';
|
||||||
const NON_TRANSLATION_CLASS = 'Symfony\Bridge\Propel1\Tests\Fixtures\Item';
|
const NON_TRANSLATION_CLASS = 'Symfony\Bridge\Propel1\Tests\Fixtures\Item';
|
||||||
|
|
||||||
protected function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getExtensions()
|
protected function getExtensions()
|
||||||
{
|
{
|
||||||
return array_merge(parent::getExtensions(), array(
|
return array(new PropelExtension());
|
||||||
new PropelExtension(),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTranslationsAdded()
|
public function testTranslationsAdded()
|
||||||
|
@ -466,7 +466,12 @@ class Configuration implements ConfigurationInterface
|
|||||||
->info('validation configuration')
|
->info('validation configuration')
|
||||||
->canBeEnabled()
|
->canBeEnabled()
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('cache')->end()
|
->scalarNode('cache')
|
||||||
|
->beforeNormalization()
|
||||||
|
// Can be removed in 3.0, once ApcCache support is dropped
|
||||||
|
->ifString()->then(function ($v) { return 'apc' === $v ? 'validator.mapping.cache.apc' : $v; })
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
->booleanNode('enable_annotations')->defaultFalse()->end()
|
->booleanNode('enable_annotations')->defaultFalse()->end()
|
||||||
->arrayNode('static_method')
|
->arrayNode('static_method')
|
||||||
->defaultValue(array('loadValidatorMetadata'))
|
->defaultValue(array('loadValidatorMetadata'))
|
||||||
|
@ -741,7 +741,7 @@ class FrameworkExtension extends Extension
|
|||||||
'validator_'.hash('sha256', $container->getParameter('kernel.root_dir'))
|
'validator_'.hash('sha256', $container->getParameter('kernel.root_dir'))
|
||||||
);
|
);
|
||||||
|
|
||||||
$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference('validator.mapping.cache.'.$config['cache'])));
|
$validatorBuilder->addMethodCall('setMetadataCache', array(new Reference($config['cache'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($config['api']) {
|
switch ($config['api']) {
|
||||||
|
Reference in New Issue
Block a user