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;
/**
* 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
* process:
* uid:
......@@ -28,6 +30,12 @@ use Drupal\migrate\Row;
* default_value: editorial
* @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(
* id = "default_entity_value",
* handle_multiples = TRUE
......
......@@ -23,7 +23,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* specified. Optionally, the field property should be specified if it is not
* 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:
* @code
......@@ -32,10 +37,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* plugin: entity_value
* source: field_noderef/0/target_id
* entity_type: node
* langcode: en
* langcode: es
* field_name: field_foo
* @endcode
*
* In this example field_foo field value will be retrieved from Spanish
* translation of the loaded node.
*
* @MigrateProcessPlugin(
* id = "entity_value",
* )
......
......@@ -11,6 +11,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* 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:
*
* @code
......@@ -40,12 +49,6 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* - constants/slash
* @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
*
* @MigrateProcessPlugin(
......
......@@ -9,58 +9,60 @@ use Drupal\migrate\ProcessPluginBase;
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(
* id = "str_replace"
* )
* Available configuration keys:
* - 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:
* @code
* field_text:
* plugin: str_replace
* source: text
* search: foo
* replace: bar
* search: et
* replace: that
* @endcode
* If the value of text is "vero eos et accusam et justo vero" in source, foo is
* "et" in search and bar is "that" in replace, field_text will be "vero eos
* that accusam that justo vero".
* If the value of text is "vero eos et accusam et justo vero" in source,
* field_text will be "vero eos that accusam that justo vero".
*
* Case insensitive searches can be achieved using the following:
* Case-insensitive searches can be achieved using the following:
* @code
* field_text:
* plugin: str_replace
* case_insensitive: true
* source: text
* search: foo
* replace: bar
* search: vero
* replace: that
* @endcode
* If the value of text is "VERO eos et accusam et justo vero" in source, foo is
* "vero" in search and bar is "that" in replace, field_text will be "that eos
* et accusam et justo that".
* If the value of text is "VERO eos et accusam et justo vero" in source,
* field_text will be "that eos et accusam et justo that".
*
* Also regular expressions can be matched using:
* Also, regular expressions can be matched using:
* @code
* field_text:
* plugin: str_replace
* regex: true
* source: text
* search: foo
* replace: bar
* search: /[0-9]{3}/
* replace: the
* @endcode
* 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
* "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.
* field_text will be "vero eos et the accusam et justo the duo".
*
* Multiple values can be matched like this:
* @code
......@@ -77,14 +79,14 @@ use Drupal\migrate\Row;
* plugin: str_replace
* regex: true
* source: text
* search: foo
* replace: bar
* search: /@(\S+)/
* replace: $1
* @endcode
* If the value of text is "@username" in source,
* foo is "/@(\S+)/" in search and bar is "$1" in replace, field_text will be
* "username".
* If the value of text is "@username" in source, field_text will be "username".
*
* @codingStandardsIgnoreEnd
* @MigrateProcessPlugin(
* id = "str_replace"
* )
*/
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