final class LayoutBuilderTranslationAccessCheck in Layout Builder Symmetric Translations 8
Provides an access check for the Layout Builder translations.
@internal Tagged services are internal.
Hierarchy
- class \Drupal\layout_builder_st\Access\LayoutBuilderTranslationAccessCheck implements AccessInterface uses LayoutEntityHelperTrait, TranslationsHelperTrait
Expanded class hierarchy of LayoutBuilderTranslationAccessCheck
1 string reference to 'LayoutBuilderTranslationAccessCheck'
1 service uses LayoutBuilderTranslationAccessCheck
File
- src/
Access/ LayoutBuilderTranslationAccessCheck.php, line 20
Namespace
Drupal\layout_builder_st\AccessView source
final class LayoutBuilderTranslationAccessCheck implements AccessInterface {
use LayoutEntityHelperTrait;
use TranslationsHelperTrait;
/**
* Checks routing access to the default translation only layout.
*
* @param \Drupal\layout_builder\SectionStorageInterface $section_storage
* The section storage.
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result.
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LayoutBuilderTranslationAccessCheck:: |
public | function | Checks routing access to the default translation only layout. | |
LayoutEntityHelperTrait:: |
protected | property | The section storage manager. | 1 |
LayoutEntityHelperTrait:: |
protected | function | Gets the sections for an entity if any. | |
LayoutEntityHelperTrait:: |
protected | function | Gets components that have Inline Block plugins. | |
LayoutEntityHelperTrait:: |
protected | function | Gets revision IDs for layout sections. | |
LayoutEntityHelperTrait:: |
protected | function | Gets the section storage for an entity. | |
LayoutEntityHelperTrait:: |
protected | function | Determines if an entity is using a field for the layout override. | |
LayoutEntityHelperTrait:: |
protected | function | Determines if an entity can have a layout. | |
LayoutEntityHelperTrait:: |
protected | function | Determines if the original entity used the default section storage. | |
LayoutEntityHelperTrait:: |
private | function | Gets the section storage manager. | 1 |
TranslationsHelperTrait:: |
protected static | function | Determines if the sections is for a translation. |