public function LayoutBuilderTranslationAccessCheck::access in Layout Builder Symmetric Translations 8
Checks routing access to the default translation only layout.
Parameters
\Drupal\layout_builder\SectionStorageInterface $section_storage: The section storage.
\Symfony\Component\Routing\Route $route: The route to check against.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
File
- src/
Access/ LayoutBuilderTranslationAccessCheck.php, line 36
Class
- LayoutBuilderTranslationAccessCheck
- Provides an access check for the Layout Builder translations.
Namespace
Drupal\layout_builder_st\AccessCode
public function access(SectionStorageInterface $section_storage, Route $route) {
$translation_type = $route
->getRequirement('_layout_builder_translation_access');
$is_translation = static::isTranslation($section_storage);
switch ($translation_type) {
case 'untranslated':
$access = AccessResult::allowedIf(!$is_translation);
break;
case 'translated':
$access = AccessResult::allowedIf($is_translation);
break;
default:
throw new \UnexpectedValueException("Unexpected _layout_builder_translation_access route requirement: {$translation_type}");
}
return $access;
}