Skip to content
Snippets Groups Projects
Unverified Commit 1aa961aa authored by Lucas Hedding's avatar Lucas Hedding
Browse files

Merge remote-tracking branch 'origin/8.x-5.x' into 6.0.x

parents d346b0b1 996e4f18
No related branches found
No related tags found
1 merge request!8Issue #3229479: Entity_lookup taxonomy_term restricted by VID
...@@ -10,9 +10,11 @@ use Drupal\migrate\Row; ...@@ -10,9 +10,11 @@ use Drupal\migrate\Row;
/** /**
* Returns EntityLookup for a given default value if input is empty. * Returns EntityLookup for a given default value if input is empty.
* *
* @see \Drupal\migrate_plus\Plugin\migrate\process\EntityLookup * Available configuration keys:
* - default_value: The default value that will be used as for the entity lookup.
* For additional configuration keys, refer to the parent class.
* *
* Example usage with full configuration: * Example:
* @code * @code
* process: * process:
* uid: * uid:
...@@ -28,6 +30,12 @@ use Drupal\migrate\Row; ...@@ -28,6 +30,12 @@ use Drupal\migrate\Row;
* default_value: editorial * default_value: editorial
* @endcode * @endcode
* *
* In this example, it will look up the source value of author in the users
* migration and if not found, use entity lookup to find a user with "editorial"
* username.
*
* @see \Drupal\migrate_plus\Plugin\migrate\process\EntityLookup
*
* @MigrateProcessPlugin( * @MigrateProcessPlugin(
* id = "default_entity_value", * id = "default_entity_value",
* handle_multiples = TRUE * handle_multiples = TRUE
......
...@@ -23,7 +23,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -23,7 +23,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* specified. Optionally, the field property should be specified if it is not * specified. Optionally, the field property should be specified if it is not
* the default of 'value'. * the default of 'value'.
* *
* For content entities, if a langcode is given, that translation is loaded. * Available configuration keys:
* - entity_type: The entity type ID to query for.
* - field_name: The machine name of the field to be extracted from the loaded
* entity.
* - langcode: (optional) The language code of entity translation. If given, the
* entity translation is loaded. It can only be used with content entities.
* *
* Example: * Example:
* @code * @code
...@@ -32,10 +37,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -32,10 +37,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* plugin: entity_value * plugin: entity_value
* source: field_noderef/0/target_id * source: field_noderef/0/target_id
* entity_type: node * entity_type: node
* langcode: en * langcode: es
* field_name: field_foo * field_name: field_foo
* @endcode * @endcode
* *
* In this example field_foo field value will be retrieved from Spanish
* translation of the loaded node.
*
* @MigrateProcessPlugin( * @MigrateProcessPlugin(
* id = "entity_value", * id = "entity_value",
* ) * )
......
...@@ -11,6 +11,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -11,6 +11,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Provides a plugin to use a callable from a service class. * Provides a plugin to use a callable from a service class.
* *
* Available configuration keys:
* - service: The ID of the service (e.g. file.mime_type.guesser).
* - method: The name of the service public method.
* All options for the callback plugin can be used, except for 'callable',
* which will be ignored.
*
* Since Drupal 9.2.0, it is possible to supply multiple arguments using
* unpack_source property. See: https://www.drupal.org/node/3205079
*
* Examples: * Examples:
* *
* @code * @code
...@@ -40,12 +49,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -40,12 +49,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* - constants/slash * - constants/slash
* @endcode * @endcode
* *
* Since Drupal 9.2.0, it is possible to supply multiple arguments using
* unpack_source property. See: https://www.drupal.org/node/3205079
*
* All options for the callback plugin can be used, except for 'callable',
* which will be ignored.
*
* @see \Drupal\migrate\Plugin\migrate\process\Callback * @see \Drupal\migrate\Plugin\migrate\process\Callback
* *
* @MigrateProcessPlugin( * @MigrateProcessPlugin(
......
...@@ -9,58 +9,60 @@ use Drupal\migrate\ProcessPluginBase; ...@@ -9,58 +9,60 @@ use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\Row; use Drupal\migrate\Row;
/** /**
* Uses the str_replace() method on a source string. * Uses either str_replace() or preg_replace() function on a source string.
* *
* @MigrateProcessPlugin( * Available configuration keys:
* id = "str_replace" * - search: The value or pattern being searched for. It can be either a string
* ) * or an array with strings.
* - replace: The replacement value that replaces found search values. It can be
* either a string or an array with strings.
* - regex: (optional) If not empty, then preg_replace() function will be used
* instead of str_replace(). Defaults to FALSE.
* - case_insensitive: (optional) If not empty, then str_ireplace() function
* will be used instead of str_replace(). Defaults to FALSE. Ignored if
* 'regex' is enabled.
* *
* @codingStandardsIgnoreStart * Depending on the value of 'regex', the rules for
* @link http://php.net/manual/function.str-replace.php str_replace @endlink
* or
* @link http://php.net/manual/function.preg-replace.php preg_replace @endlink
* apply. This means that you can provide arrays as values, your replace string
* can include backreferences, etc.
* *
* To do a simple hardcoded string replace, use the following: * To do a simple hardcoded string replace, use the following:
* @code * @code
* field_text: * field_text:
* plugin: str_replace * plugin: str_replace
* source: text * source: text
* search: foo * search: et
* replace: bar * replace: that
* @endcode * @endcode
* If the value of text is "vero eos et accusam et justo vero" in source, foo is * If the value of text is "vero eos et accusam et justo vero" in source,
* "et" in search and bar is "that" in replace, field_text will be "vero eos * field_text will be "vero eos that accusam that justo vero".
* that accusam that justo vero".
* *
* Case insensitive searches can be achieved using the following: * Case-insensitive searches can be achieved using the following:
* @code * @code
* field_text: * field_text:
* plugin: str_replace * plugin: str_replace
* case_insensitive: true * case_insensitive: true
* source: text * source: text
* search: foo * search: vero
* replace: bar * replace: that
* @endcode * @endcode
* If the value of text is "VERO eos et accusam et justo vero" in source, foo is * If the value of text is "VERO eos et accusam et justo vero" in source,
* "vero" in search and bar is "that" in replace, field_text will be "that eos * field_text will be "that eos et accusam et justo that".
* et accusam et justo that".
* *
* Also regular expressions can be matched using: * Also, regular expressions can be matched using:
* @code * @code
* field_text: * field_text:
* plugin: str_replace * plugin: str_replace
* regex: true * regex: true
* source: text * source: text
* search: foo * search: /[0-9]{3}/
* replace: bar * replace: the
* @endcode * @endcode
* If the value of text is "vero eos et 123 accusam et justo 123 duo" in source, * If the value of text is "vero eos et 123 accusam et justo 123 duo" in source,
* foo is "/[0-9]{3}/" in search and bar is "the" in replace, field_text will be * field_text will be "vero eos et the accusam et justo the duo".
* "vero eos et the accusam et justo the duo".
*
* Depending on the value of 'regex', the rules for
* @link http://php.net/manual/function.str-replace.php str_replace @endlink
* or
* @link http://php.net/manual/function.preg-replace.php preg_replace @endlink
* apply. This means that you can provide arrays as values, your replace string
* can include backreferences, etc.
* *
* Multiple values can be matched like this: * Multiple values can be matched like this:
* @code * @code
...@@ -77,14 +79,14 @@ use Drupal\migrate\Row; ...@@ -77,14 +79,14 @@ use Drupal\migrate\Row;
* plugin: str_replace * plugin: str_replace
* regex: true * regex: true
* source: text * source: text
* search: foo * search: /@(\S+)/
* replace: bar * replace: $1
* @endcode * @endcode
* If the value of text is "@username" in source, * If the value of text is "@username" in source, field_text will be "username".
* foo is "/@(\S+)/" in search and bar is "$1" in replace, field_text will be
* "username".
* *
* @codingStandardsIgnoreEnd * @MigrateProcessPlugin(
* id = "str_replace"
* )
*/ */
class StrReplace extends ProcessPluginBase { class StrReplace extends ProcessPluginBase {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment