Problem/Motivation

Drupal core is switching from Annotations to Attributes. Tamper should also provide an Attribute class so that downstream modules can start converting.

This MR converts the tamper plugin annotations into attributes. This requires Drupal 10.2 or later.

Issue fork tamper-3484089

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ptmkenny created an issue. See original summary.

ptmkenny’s picture

Title: Add attributes alongside annotations » Convert annotations to attributes in Tamper plugins
ptmkenny’s picture

Issue summary: View changes
megachriz’s picture

StatusFileSize
new75.54 KB

I do indeed get no Tamper plugin to choose from (using Feeds Tamper):

I think that TamperManager needs a change.

For example, \Drupal\filter\FilterPluginManager in Drupal 11.x has a reference to the attribute class:

use Drupal\filter\Attribute\Filter;
ptmkenny’s picture

Issue summary: View changes
ptmkenny’s picture

Title: Convert annotations to attributes in Tamper plugins » Convert annotations to attributes in Tamper plugins (requires 10.2+)
megachriz’s picture

Status: Postponed » Needs review

I've updated the conversion:

  • category is made translatable.
  • new property itemUsage is now converted too.
  • plugins that were added this year ('absolute_url', 'entity_finder' and 'twig') have now also conversions.
megachriz’s picture

Status: Needs review » Fixed

I exported the definitions from before this change and after this change and then compared the two files to see if I spotted any differences that would be an error and did not see errors. There were slight differences in the plugin's descriptions. For some plugins, single quotes in the description were replaced with double quotes. But that's no error.

I used the following code for exporting the definitions:

drupal_flush_all_caches();

$keys = [
  'id',
  'label',
  'description',
  'category',
  'handle_multiples',
  'itemUsage',
];

$rows = [];
foreach (\Drupal::service('plugin.manager.tamper')->getDefinitions() as $definition) {
  $row = [];
  foreach ($keys as $key) {
    if (!array_key_exists($key, $definition)) {
      $row[$key] = 'undefined';
    }
    elseif (is_object($definition[$key])) {
      $row[$key] = (string) $definition[$key] .  ' (' . get_class($definition[$key]) . ')';
    }
    else {
      ob_start();
      var_dump($definition[$key]);
      $row[$key] = ob_get_clean();
      $row[$key] = trim($row[$key]);
    }
  }
  $rows[$definition['id']] = $row;
}
ksort($rows);

file_put_contents('/tmp/defs2.txt', print_r($rows, TRUE));

This is good, so I've scheduled to merge the changes.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • megachriz committed 6a9320f3 on 8.x-1.x authored by ptmkenny
    feat: #3484089 Convert annotations to attributes in Tamper plugins (...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.