diff --git a/modules/core/quick/farm_quick.links.task.yml b/modules/core/quick/farm_quick.links.task.yml new file mode 100644 index 000000000..fc20fde76 --- /dev/null +++ b/modules/core/quick/farm_quick.links.task.yml @@ -0,0 +1,2 @@ +farm.quick: + deriver: Drupal\farm_quick\Plugin\Derivative\QuickFormTaskLink diff --git a/modules/core/quick/src/Plugin/Derivative/QuickFormTaskLink.php b/modules/core/quick/src/Plugin/Derivative/QuickFormTaskLink.php new file mode 100644 index 000000000..6b4059490 --- /dev/null +++ b/modules/core/quick/src/Plugin/Derivative/QuickFormTaskLink.php @@ -0,0 +1,77 @@ +quickFormInstanceManager = $quick_form_instance_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, $base_plugin_id) { + return new static( + $container->get('quick_form.instance_manager') + ); + } + + /** + * {@inheritdoc} + */ + public function getDerivativeDefinitions($base_plugin_definition) { + $links = []; + + // Load quick forms. + $quick_forms = $this->quickFormInstanceManager->getInstances(); + + // Add links for each quick form. + foreach ($quick_forms as $id => $quick_form) { + $route_name = 'farm.quick.' . $id; + $links[$route_name] = [ + 'title' => $this->t('Quick form'), + 'route_name' => $route_name, + 'base_route' => $route_name, + 'weight' => 0, + ] + $base_plugin_definition; + + // If the quick form is configurable, add a link to the config form. + if ($quick_form->getPlugin()->isConfigurable()) { + $links[$route_name . '.configure'] = [ + 'title' => $this->t('Configure'), + 'route_name' => $route_name . '.configure', + 'base_route' => $route_name, + 'weight' => 100, + ] + $base_plugin_definition; + } + } + + return $links; + } + +}