class WizardEnhancer

Same name in other branches
  1. 4.0.x src/Routing/Enhancer/WizardEnhancer.php \Drupal\ctools\Routing\Enhancer\WizardEnhancer

Sets the request format onto the request object.

Hierarchy

Expanded class hierarchy of WizardEnhancer

1 string reference to 'WizardEnhancer'
ctools.services.yml in ./ctools.services.yml
ctools.services.yml
1 service uses WizardEnhancer
ctools.wizard_enhancer in ./ctools.services.yml
Drupal\ctools\Routing\Enhancer\WizardEnhancer

File

src/Routing/Enhancer/WizardEnhancer.php, line 13

Namespace

Drupal\ctools\Routing\Enhancer
View source
class WizardEnhancer implements EnhancerInterface {
    
    /**
     * {@inheritdoc}
     */
    public function enhance(array $defaults, Request $request) {
        $route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
        if (!$this->isApplicable($route)) {
            return $defaults;
        }
        if (!empty($defaults['_wizard'])) {
            $defaults['_controller'] = 'ctools.wizard.form:getContentResult';
        }
        if (!empty($defaults['_entity_wizard'])) {
            $defaults['_controller'] = 'ctools.wizard.entity.form:getContentResult';
        }
        return $defaults;
    }
    
    /**
     * Returns if current route use ctools default parameters.
     *
     * @param \Symfony\Component\Routing\Route $route
     *   The route to check.
     *
     * @return bool
     *   TRUE if the route use one of ctools route default parameters or FALSE.
     */
    public function isApplicable(Route $route) {
        return !$route->hasDefault('_controller') && ($route->hasDefault('_wizard') || $route->hasDefault('_entity_wizard'));
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
WizardEnhancer::enhance public function Updates the defaults for a route definition based on the request. Overrides EnhancerInterface::enhance
WizardEnhancer::isApplicable public function Returns if current route use ctools default parameters.