Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291641

Extended callback process plugin to call functions with multiple parameters

$
0
0

Problem/Motivation

It would be nice to be able to call functions which requires more than just one parameter. For example, ltrim($str, $character_mask).

Proposed resolution

Add the optional parameter unpack_source to the callback plugin. When set, the source value passed to the plugin must be an array, and it is interpreted as a list of arguments. This can be implemented by using call_user_func_array() instead of call_user_func().

Here is a complete example using the new option:

id: callback_test
label: Test the callback process plugin.
source:
  plugin: embedded_data
  data_rows:
    - id: 1
      url: https://www.example.com/
    - id: 2
      url: https://www.drupal.org
  ids:
    id:
      type: integer
  constants:
    slash: /
destination:
  plugin: entity:taxonomy_term
  default_bundle: tags
process:
  tid: id
  name:
    - plugin: callback
      callable: rtrim
      unpack_source: true
      source:
        - url
        - constants/slash
    - plugin: log

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None


Viewing all articles
Browse latest Browse all 291641

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>