From 1f20fb1b7d07867b2024d3d8e9eb9c121f353f8d Mon Sep 17 00:00:00 2001 From: William DURAND Date: Sat, 11 Feb 2012 01:15:30 +0100 Subject: [PATCH] [Propel] Removed useless code --- .../Propel1/Form/ChoiceList/ModelChoiceList.php | 12 ++---------- .../DataTransformer/CollectionToArrayTransformer.php | 12 ------------ src/Symfony/Bridge/Propel1/Form/Type/ModelType.php | 3 ++- 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php index f630b0e558..ff71fe6de1 100644 --- a/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php +++ b/src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php @@ -18,7 +18,7 @@ use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; use \Persistent; /** - * Widely inspirated by the EntityChoiceList (Symfony2). + * Widely inspirated by the EntityChoiceList. * * @author William Durand */ @@ -33,13 +33,6 @@ class ModelChoiceList extends ObjectChoiceList */ private $identifier = array(); - /** - * TableMap - * - * @var \TableMap - */ - private $table = null; - /** * Query */ @@ -66,8 +59,7 @@ class ModelChoiceList extends ObjectChoiceList $queryClass = $this->class . 'Query'; $query = new $queryClass(); - $this->table = $query->getTableMap(); - $this->identifier = $this->table->getPrimaryKeys(); + $this->identifier = $query->getTableMap()->getPrimaryKeys(); $this->query = $queryObject ?: $query; $this->loaded = is_array($choices) || $choices instanceof \Traversable; diff --git a/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php b/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php index 0a49789c1f..ff1399b987 100644 --- a/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php +++ b/src/Symfony/Bridge/Propel1/Form/DataTransformer/CollectionToArrayTransformer.php @@ -11,13 +11,11 @@ namespace Symfony\Bridge\Propel1\Form\DataTransformer; -use Symfony\Bridge\Propel1\Form\ChoiceList\ModelChoiceList; use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\UnexpectedTypeException; use Symfony\Component\Form\Exception\TransformationFailedException; use \PropelCollection; -use \PropelObjectCollection; /** * CollectionToArrayTransformer class. @@ -27,16 +25,6 @@ use \PropelObjectCollection; */ class CollectionToArrayTransformer implements DataTransformerInterface { - /** - * @var \Symfony\Bridge\Propel1\Form\ChoiceList\ModelChoiceList - */ - private $choiceList; - - public function __construct(ModelChoiceList $choiceList) - { - $this->choiceList = $choiceList; - } - public function transform($collection) { if (null === $collection) { diff --git a/src/Symfony/Bridge/Propel1/Form/Type/ModelType.php b/src/Symfony/Bridge/Propel1/Form/Type/ModelType.php index fd6e5650f8..d12b8c32ac 100644 --- a/src/Symfony/Bridge/Propel1/Form/Type/ModelType.php +++ b/src/Symfony/Bridge/Propel1/Form/Type/ModelType.php @@ -27,7 +27,7 @@ class ModelType extends AbstractType public function buildForm(FormBuilder $builder, array $options) { if ($options['multiple']) { - $builder->prependClientTransformer(new CollectionToArrayTransformer($options['choice_list'])); + $builder->prependClientTransformer(new CollectionToArrayTransformer()); } } @@ -42,6 +42,7 @@ class ModelType extends AbstractType 'query' => null, 'choices' => null, 'group_by' => null, + 'by_reference' => false, ); $options = array_replace($defaultOptions, $options);