3 namespace Drupal\ctools\Controller;
5 use Drupal\Core\Controller\ControllerResolverInterface;
6 use Drupal\Core\Entity\EntityManagerInterface;
7 use Drupal\Core\Form\FormBuilderInterface;
8 use Drupal\Core\Routing\RouteMatchInterface;
9 use Drupal\ctools\Wizard\WizardFactoryInterface;
12 * Wrapping controller for wizard forms that serve as the main page body.
14 class WizardEntityFormController extends WizardFormController {
17 * The entity manager service.
19 * @var \Drupal\Core\Entity\EntityManagerInterface
21 protected $entityManager;
24 * @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver
25 * The controller resolver.
26 * @param \Drupal\Core\Form\FormBuilderInterface $form_builder
28 * @param \Drupal\ctools\Wizard\WizardFactoryInterface $wizard_factory
30 * @param \Drupal\Core\Entity\EntityManagerInterface $manager
33 public function __construct(ControllerResolverInterface $controller_resolver, FormBuilderInterface $form_builder, WizardFactoryInterface $wizard_factory, EntityManagerInterface $manager) {
34 parent::__construct($controller_resolver, $form_builder, $wizard_factory);
35 $this->entityManager = $manager;
41 protected function getFormArgument(RouteMatchInterface $route_match) {
42 $form_arg = $route_match->getRouteObject()->getDefault('_entity_wizard');
43 list($entity_type_id, $operation) = explode('.', $form_arg);
44 $definition = $this->entityManager->getDefinition($entity_type_id);
45 $handlers = $definition->getHandlerClasses();
46 if (empty($handlers['wizard'][$operation])) {
47 throw new \Exception(sprintf('Unsupported wizard operation %s', $operation));
49 return $handlers['wizard'][$operation];