You are here

public function PluginHelperTrait::getUntranslatedCategory in Layout Builder Restrictions 8.2

Helper function to return an untranslated block Category.

Parameters

mixed $category: The block category name or object.

Return value

string A string representing the untranslated block category.

5 calls to PluginHelperTrait::getUntranslatedCategory()
EntityViewModeRestriction::alterBlockDefinitions in src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php
Alter the block definitions.
EntityViewModeRestriction::blockAllowedinContext in src/Plugin/LayoutBuilderRestriction/EntityViewModeRestriction.php
Determine whether the block being moved is allowed to the destination.
EntityViewModeRestrictionByRegion::alterBlockDefinitions in modules/layout_builder_restrictions_by_region/src/Plugin/LayoutBuilderRestriction/EntityViewModeRestrictionByRegion.php
Alter the block definitions.
EntityViewModeRestrictionByRegion::blockAllowedinContext in modules/layout_builder_restrictions_by_region/src/Plugin/LayoutBuilderRestriction/EntityViewModeRestrictionByRegion.php
Determine whether the block being moved is allowed to the destination.
PluginHelperTrait::getGroupedDefinitions in src/Traits/PluginHelperTrait.php
Method to categorize blocks in a multilingual-friendly way.

File

src/Traits/PluginHelperTrait.php, line 178

Class

PluginHelperTrait
Methods to help Layout Builder Restrictions plugins.

Namespace

Drupal\layout_builder_restrictions\Traits

Code

public function getUntranslatedCategory($category) {
  if ($category instanceof TranslatableMarkup) {
    $output = $category
      ->getUntranslatedString();

    // Rename to match Layout Builder Restrictions naming.
    if ($output == '@entity fields') {
      $output = 'Content fields';
    }
    if ($output == "Custom") {
      $output = "Custom blocks";
    }
  }
  else {
    $output = (string) $category;
  }
  return $output;
}