SmartDateFormatHtmlRouteProvider.php in Smart Date 3.4.x
File
src/Entity/SmartDateFormatHtmlRouteProvider.php
View source
<?php
namespace Drupal\smart_date\Entity;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;
class SmartDateFormatHtmlRouteProvider extends AdminHtmlRouteProvider {
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
$entity_type_id = $entity_type
->id();
if ($settings_form_route = $this
->getSettingsFormRoute($entity_type)) {
$collection
->add("{$entity_type_id}.settings", $settings_form_route);
}
return $collection;
}
protected function getSettingsFormRoute(EntityTypeInterface $entity_type) {
if (!$entity_type
->getBundleEntityType()) {
$route = new Route("/admin/config/regional/smart_date_format/settings");
$route
->setDefaults([
'_form' => 'Drupal\\smart_date\\Form\\SmartDateFormatSettingsForm',
'_title' => "{$entity_type->getLabel()} settings",
])
->setRequirement('_permission', $entity_type
->getAdminPermission())
->setOption('_admin_route', TRUE);
return $route;
}
}
}