RouteSubscriber.php in Layout Builder Symmetric Translations 8
File
src/Routing/RouteSubscriber.php
View source
<?php
namespace Drupal\layout_builder_st\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Drupal\Core\Routing\RoutingEvents;
use Symfony\Component\Routing\RouteCollection;
final class RouteSubscriber extends RouteSubscriberBase {
protected function alterRoutes(RouteCollection $collection) {
foreach ($collection
->all() as $route) {
if ($route
->getRequirement('_layout_builder_access') === 'view' && !$route
->hasRequirement('_layout_builder_translation_access')) {
$route
->setRequirement('_layout_builder_translation_access', 'untranslated');
}
}
}
public static function getSubscribedEvents() {
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
100,
];
return $events;
}
}