Version 1
[yaffs-website] / web / modules / contrib / ctools / src / Routing / Enhancer / WizardEnhancer.php
diff --git a/web/modules/contrib/ctools/src/Routing/Enhancer/WizardEnhancer.php b/web/modules/contrib/ctools/src/Routing/Enhancer/WizardEnhancer.php
new file mode 100644 (file)
index 0000000..3e125eb
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+
+namespace Drupal\ctools\Routing\Enhancer;
+
+use Drupal\Core\Routing\Enhancer\RouteEnhancerInterface;
+use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\Routing\Route;
+
+/**
+ * Sets the request format onto the request object.
+ */
+class WizardEnhancer implements RouteEnhancerInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function applies(Route $route) {
+    return !$route->hasDefault('_controller') && ($route->hasDefault('_wizard') || $route->hasDefault('_entity_wizard'));
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function enhance(array $defaults, Request $request) {
+    if (!empty($defaults['_wizard'])) {
+      $defaults['_controller'] = 'ctools.wizard.form:getContentResult';
+    }
+    if (!empty($defaults['_entity_wizard'])) {
+      $defaults['_controller'] = 'ctools.wizard.entity.form:getContentResult';
+    }
+    return $defaults;
+  }
+
+}