--- a/src/Plugin/RulesDataProcessor/NumericOffset.php +++ b/src/Plugin/RulesDataProcessor/NumericOffset.php @@ -5,6 +5,7 @@ use Drupal\Core\Plugin\PluginBase; use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\rules\Attribute\RulesDataProcessor; +use Drupal\rules\Context\ContextDefinitionInterface; use Drupal\rules\Context\DataProcessorInterface; use Drupal\rules\Context\ExecutionStateInterface; @@ -27,6 +28,14 @@ /** * {@inheritdoc} + */ + public function canProcess(ContextDefinitionInterface $context_definition) { + $data_type = $context_definition->getDataDefinition()->getDataType(); + return in_array($data_type, ['integer', 'float', 'decimal']); + } + + /** + * {@inheritdoc} */ public function process($value, ExecutionStateInterface $rules_state) { return $value + $this->configuration['offset'];