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\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;
}