You are here

protected function HookPermission::castTranslatables in Drupal 7 to 8/9 Module Upgrader 8

Casts translatable string objects in a permissions array to strings.

Parameters

array $permissions: An array of permissions, as returned by hook_permission().

Return value

array The permissions array, with all TranslatableString objects casted to strings.

1 call to HookPermission::castTranslatables()
HookPermission::convert in src/Plugin/DMU/Converter/HookPermission.php
Performs required conversions.

File

src/Plugin/DMU/Converter/HookPermission.php, line 36

Class

HookPermission
Plugin annotation @Converter( id = "hook_permission", description = @Translation("Converts static implementations of hook_permission() to YAML."), hook = "hook_permission" )

Namespace

Drupal\drupalmoduleupgrader\Plugin\DMU\Converter

Code

protected function castTranslatables($permissions) {
  array_walk_recursive($permissions, function (&$value) {
    if ($value instanceof MarkupInterface) {
      $value = (string) $value;
    }
  });
  return $permissions;
}