public function ShortcutSetUsers::import in Drupal 8
Same name and namespace in other branches
- 9 core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php \Drupal\shortcut\Plugin\migrate\destination\ShortcutSetUsers::import()
- 10 core/modules/shortcut/src/Plugin/migrate/destination/ShortcutSetUsers.php \Drupal\shortcut\Plugin\migrate\destination\ShortcutSetUsers::import()
Import the row.
Derived classes must implement import(), to construct one new object (pre-populated) using ID mappings in the Migration.
Parameters
\Drupal\migrate\Row $row: The row object.
array $old_destination_id_values: (optional) The old destination IDs. Defaults to an empty array.
Return value
array|bool An indexed array of destination IDs in the same order as defined in the plugin's getIds() method if the plugin wants to save the IDs to the ID map, TRUE to indicate success without saving IDs to the ID map, or FALSE to indicate a failure.
Overrides MigrateDestinationInterface::import
File
- core/
modules/ shortcut/ src/ Plugin/ migrate/ destination/ ShortcutSetUsers.php, line 86
Class
- ShortcutSetUsers
- Plugin annotation @MigrateDestination( id = "shortcut_set_users" )
Namespace
Drupal\shortcut\Plugin\migrate\destinationCode
public function import(Row $row, array $old_destination_id_values = []) {
/** @var \Drupal\shortcut\ShortcutSetInterface $set */
$set = $this->shortcutSetStorage
->load($row
->getDestinationProperty('set_name'));
/** @var \Drupal\user\UserInterface $account */
$account = User::load($row
->getDestinationProperty('uid'));
$this->shortcutSetStorage
->assignUser($set, $account);
return [
$set
->id(),
$account
->id(),
];
}