3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Build routes to configuration forms.

This commit is contained in:
Michael Stenta 2023-03-13 09:34:24 -04:00
parent 92c3543b87
commit 87fa34716d

View file

@ -3,6 +3,7 @@
namespace Drupal\farm_quick\Routing;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\farm_quick\Form\ConfigureQuickForm;
use Drupal\farm_quick\Form\QuickForm;
use Drupal\farm_quick\QuickFormInstanceManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -51,6 +52,8 @@ class QuickFormRoutes implements ContainerInjectionInterface {
/** @var \Drupal\farm_quick\Entity\QuickFormInstanceInterface[] $quick_forms */
$quick_forms = $this->quickFormInstanceManager->getInstances();
foreach ($quick_forms as $id => $quick_form) {
// Build a route for the quick form.
$route = new Route(
"/quick/$id",
[
@ -63,6 +66,23 @@ class QuickFormRoutes implements ContainerInjectionInterface {
],
);
$route_collection->add("farm.quick.$id", $route);
// If the quick form is configurable, build a route for the configuration
// form.
if ($quick_form->getPlugin()->isConfigurable()) {
$route = new Route(
"/quick/$id/configure",
[
'_form' => ConfigureQuickForm::class,
'_title_callback' => ConfigureQuickForm::class . '::getTitle',
'id' => $id,
],
[
'_custom_access' => ConfigureQuickForm::class . '::access',
],
);
$route_collection->add("farm.quick.$id.configure", $route);
}
}
return $route_collection;
}