This project is not covered by Drupal’s security advisory policy.

This module allows you to execute any RPN calculation on the value of a field
when a hook fires. The module is a nuclear plugin and as such it can act on every fieldable entity argument of
the hook and then traverse recursively any entity references. Then it will
check every field of the entities and check for the third party setting called
nuclear then it will use this module if the plugin is set to rpn. The RPN calculation is specified in the configuration.rpn key. The RPN stack starts with the field value. Examples below.

Currently, there is no nice UI.

Let's say we want to give 1 point every time a node is inserted.

Create an integer field (in my example, it is on user) and then head over to
admin/config/development/configuration/single/export.

Export the field and add this:

third_party_settings:
  nuclear:
    node_insert/uid:
      plugin: rpn
      configuration: 
        rpn: '1 +'

This means

1. the first argument of hook node_insert. If it'd be the second, you'd need
node_insert/1/uid

2. Using this argumemnt, the field uid points to our user. Longer chains are
possible.

This is not all! You can use tokens like this:

third_party_settings:
  nuclear:
    node_insert/uid:
      plugin: rpn
      configuration: 
        rpn: '[@node_insert:type] article == +'

This will add 1 points for inserting an article, 0 otherwise.

Another example, for the flag module flagging_insert/flagged_entity/uid points to the author of the flagged comment or node.

third_party_settings:
  nuclear:
    flagging_insert/flagged_entity/uid:
      plugin: rpn
      configuration: 
        rpn: '[@flagging_insert/flagged_entity:type] article == +'

This will add 1 points to the author of a flagged article. Other flagged content doesn't grant points.

In other words, write an "entity path" between the @ and : and the rpn_field module will replace with the relevant entity type and provide the relevant entity to the token system. After the : the normal tokens can be used.

Image source XKCD 645.

Supporting organizations: 

Project information

  • caution Seeking new maintainer
    The current maintainers are looking for new people to take ownership.
  • Module categories: Site Structure
  • Created by chx on , updated
  • shield alertThis project is not covered by the security advisory policy.
    Use at your own risk! It may have publicly disclosed vulnerabilities.

Releases