Skip to content
Snippets Groups Projects

Issue #3300556: Plugins should accept tokens

Merged Jürgen Haas requested to merge issue/eca_tamper-3300556:3300556-tamper-math-plugin into 1.0.x
2 files
+ 27
6
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -2,7 +2,6 @@
namespace Drupal\eca_tamper\Plugin\Action;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Form\FormStateInterface;
use Drupal\eca\Plugin\Action\ConfigurableActionBase;
use Drupal\eca_tamper\Plugin\TamperTrait;
@@ -34,16 +33,26 @@ class Tamper extends ConfigurableActionBase {
/**
* {@inheritdoc}
*
* @throws \Drupal\Component\Plugin\Exception\PluginException
*/
public function execute(): void {
$tamperPlugin = $this->tamperPlugin();
$config = [];
foreach ($tamperPlugin->defaultConfiguration() as $key => $value) {
if (in_array($key, ['eca_data', 'eca_token_name'])) {
continue;
}
$config[$key] = $this->tokenServices->replaceClear($this->configuration[$key]);
}
$tamperPlugin->setConfiguration($config);
$data = $this->tokenServices->replaceClear($this->configuration['eca_data']);
try {
$value = $this->tamperPlugin()->tamper($data);
$value = $tamperPlugin->tamper($data);
}
catch (PluginException | SkipTamperDataException | TamperException | SkipTamperItemException $e) {
catch (SkipTamperDataException | TamperException | SkipTamperItemException $e) {
$value = $data;
}
$this->tokenServices->addTokenData($this->configuration['eca_token_name'], $value);
}
@@ -90,6 +99,7 @@ class Tamper extends ConfigurableActionBase {
$this->configuration['eca_data'] = $form_state->getValue('eca_data');
$this->configuration['eca_token_name'] = $form_state->getValue('eca_token_name');
$this->submitTamperConfigurationForm($form, $form_state);
$this->configuration = $this->tamperPlugin()->getConfiguration() + $this->configuration;
}
}
Loading