Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RolesLookup.php

function RolesLookup::transform

Overrides ProcessPluginBase::transform

File

core/modules/block/src/Plugin/migrate/process/RolesLookup.php, line 88

Class

RolesLookup
Gets the destination roles ID for an array of source roles IDs.

Namespace

Drupal\block\Plugin\migrate\process

Code

public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
    $roles = $row->get('roles');
    $roles_result = [];
    // If the block is assigned to specific roles, add the user_role condition.
    if ($roles) {
        foreach ($roles as $role_id) {
            $lookup_result = $this->migrateLookup
                ->lookup([
                $this->migration,
            ], [
                $role_id,
            ]);
            if ($lookup_result) {
                $roles_result[$role_id] = $lookup_result[0]['id'];
            }
        }
    }
    return $roles_result;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal