doctrine-mezzio-module/src/Form/Element/ElementFactory.php
2021-01-10 19:25:40 +01:00

19 lines
498 B
PHP

<?php
namespace DoctrineMezzioModule\Form\Element;
use Interop\Container\ContainerInterface;
class ElementFactory
{
public function __invoke(ContainerInterface $container, string $elementClass, array $options = [])
{
$em = $container->get('doctrine.entity_manager.orm_default');
/** @var ObjectSelect|ObjectRadio|ObjectMultiCheckbox $element */
$element = new $elementClass();
$element->setOption('object_manager', $em);
return $element;
}
}