|
@@ -13,7 +13,9 @@ namespace Sonata\AdminBundle\Form\DataTransformer;
|
|
|
|
|
|
use Sonata\AdminBundle\Form\ChoiceList\ModelChoiceList;
|
|
use Sonata\AdminBundle\Form\ChoiceList\ModelChoiceList;
|
|
use Sonata\AdminBundle\Model\ModelManagerInterface;
|
|
use Sonata\AdminBundle\Model\ModelManagerInterface;
|
|
|
|
+use Symfony\Component\Form\ChoiceList\LazyChoiceList;
|
|
use Symfony\Component\Form\DataTransformerInterface;
|
|
use Symfony\Component\Form\DataTransformerInterface;
|
|
|
|
+use Symfony\Component\Form\Exception\RuntimeException;
|
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
|
|
|
|
|
@@ -42,12 +44,16 @@ class ModelsToArrayTransformer implements DataTransformerInterface
|
|
/**
|
|
/**
|
|
* ModelsToArrayTransformer constructor.
|
|
* ModelsToArrayTransformer constructor.
|
|
*
|
|
*
|
|
- * @param ModelChoiceList $choiceList
|
|
|
|
- * @param ModelManagerInterface $modelManager
|
|
|
|
- * @param $class
|
|
|
|
|
|
+ * @param ModelChoiceList|LazyChoiceList $choiceList
|
|
|
|
+ * @param ModelManagerInterface $modelManager
|
|
|
|
+ * @param $class
|
|
*/
|
|
*/
|
|
- public function __construct(ModelChoiceList $choiceList, ModelManagerInterface $modelManager, $class)
|
|
|
|
|
|
+ public function __construct($choiceList, ModelManagerInterface $modelManager, $class)
|
|
{
|
|
{
|
|
|
|
+ if (!$choiceList instanceof ModelChoiceList && !$choiceList instanceof LazyChoiceList) {
|
|
|
|
+ throw new RuntimeException('First param passed to ModelsToArrayTransformer should be instance of ModelChoiceList or LazyChoiceList');
|
|
|
|
+ }
|
|
|
|
+
|
|
$this->choiceList = $choiceList;
|
|
$this->choiceList = $choiceList;
|
|
$this->modelManager = $modelManager;
|
|
$this->modelManager = $modelManager;
|
|
$this->class = $class;
|
|
$this->class = $class;
|