Build routes to configuration forms.
This commit is contained in:
parent
92c3543b87
commit
87fa34716d
|
@ -3,6 +3,7 @@
|
||||||
namespace Drupal\farm_quick\Routing;
|
namespace Drupal\farm_quick\Routing;
|
||||||
|
|
||||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||||
|
use Drupal\farm_quick\Form\ConfigureQuickForm;
|
||||||
use Drupal\farm_quick\Form\QuickForm;
|
use Drupal\farm_quick\Form\QuickForm;
|
||||||
use Drupal\farm_quick\QuickFormInstanceManagerInterface;
|
use Drupal\farm_quick\QuickFormInstanceManagerInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
@ -51,6 +52,8 @@ class QuickFormRoutes implements ContainerInjectionInterface {
|
||||||
/** @var \Drupal\farm_quick\Entity\QuickFormInstanceInterface[] $quick_forms */
|
/** @var \Drupal\farm_quick\Entity\QuickFormInstanceInterface[] $quick_forms */
|
||||||
$quick_forms = $this->quickFormInstanceManager->getInstances();
|
$quick_forms = $this->quickFormInstanceManager->getInstances();
|
||||||
foreach ($quick_forms as $id => $quick_form) {
|
foreach ($quick_forms as $id => $quick_form) {
|
||||||
|
|
||||||
|
// Build a route for the quick form.
|
||||||
$route = new Route(
|
$route = new Route(
|
||||||
"/quick/$id",
|
"/quick/$id",
|
||||||
[
|
[
|
||||||
|
@ -63,6 +66,23 @@ class QuickFormRoutes implements ContainerInjectionInterface {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
$route_collection->add("farm.quick.$id", $route);
|
$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;
|
return $route_collection;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue