function RolesLookup::transform
Same name in other branches
- 11.x core/modules/block/src/Plugin/migrate/process/RolesLookup.php \Drupal\block\Plugin\migrate\process\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\processCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.