diff --git a/ctools.services.yml b/ctools.services.yml index 44313a7..046813b 100644 --- a/ctools.services.yml +++ b/ctools.services.yml @@ -5,10 +5,10 @@ services: ctools.wizard.entity.form: class: Drupal\ctools\Controller\WizardEntityFormController arguments: ['@controller_resolver', '@form_builder', '@ctools.wizard.factory', '@entity.manager'] - ctools.wizard.controller_subscriber: - class: Drupal\ctools\EventSubscriber\WizardControllerSubscriber + ctools.wizard_enhancer: + class: Drupal\ctools\Routing\Enhancer\WizardEnhancer tags: - - { name: event_subscriber } + - { name: route_enhancer } ctools.wizard.factory: class: Drupal\ctools\Wizard\WizardFactory arguments: ['@form_builder', '@event_dispatcher'] diff --git a/modules/ctools_block/src/Plugin/Block/EntityField.php b/modules/ctools_block/src/Plugin/Block/EntityField.php index f70563d..1120f09 100644 --- a/modules/ctools_block/src/Plugin/Block/EntityField.php +++ b/modules/ctools_block/src/Plugin/Block/EntityField.php @@ -358,4 +358,12 @@ class EntityField extends BlockBase implements ContextAwarePluginInterface, Cont ]); } + public function __wakeup() { + parent::__wakeup(); + // @todo figure out why this happens. + // prevent $fieldStorageDefinition being erroneously set to $this. + $this->fieldStorageDefinition = NULL; + } + + } diff --git a/src/Access/TempstoreAccess.php b/src/Access/TempstoreAccess.php index 975bfe1..ef32dfa 100644 --- a/src/Access/TempstoreAccess.php +++ b/src/Access/TempstoreAccess.php @@ -33,7 +33,7 @@ class TempstoreAccess implements CoreAccessInterface { } public function access(Route $route, RouteMatch $match, AccountInterface $account) { - $tempstore_id = $route->getDefault('tempstore_id'); + $tempstore_id = $match->getParameter('tempstore_id') ? $match->getParameter('tempstore_id') : $route->getDefault('tempstore_id'); $id = $match->getParameter($route->getRequirement('_ctools_access')); if ($tempstore_id && $id) { $cached_values = $this->getTempstore()->get($tempstore_id)->get($id); diff --git a/src/EventSubscriber/WizardControllerSubscriber.php b/src/EventSubscriber/WizardControllerSubscriber.php deleted file mode 100644 index c3a9416..0000000 --- a/src/EventSubscriber/WizardControllerSubscriber.php +++ /dev/null @@ -1,47 +0,0 @@ -getRequest(); - - if ($request->attributes->has('_wizard')) { - $request->attributes->set('_controller', 'ctools.wizard.form:getContentResult'); - } - if ($request->attributes->has('_entity_wizard')) { - $request->attributes->set('_controller', 'ctools.wizard.entity.form:getContentResult'); - } - } - - /** - * Registers the methods in this class that should be listeners. - * - * @return array - * An array of event listener definitions. - */ - static function getSubscribedEvents() { - $events[KernelEvents::REQUEST][] = array('onRequestDeriveFormWrapper', 29); - return $events; - } - -} diff --git a/src/Routing/Enhancer/WizardEnhancer.php b/src/Routing/Enhancer/WizardEnhancer.php new file mode 100644 index 0000000..8650353 --- /dev/null +++ b/src/Routing/Enhancer/WizardEnhancer.php @@ -0,0 +1,39 @@ +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; + } + +}