- Issue created by @penyaskito
- 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
In
\DrupalRector\Drupal10\Rector\Deprecation\AnnotationToAttributeRector
\DrupalRector\Drupal10\Rector\Deprecation\AnnotationToAttributeRector::convertAnnotation
Add
'@ContextDefinition' => $this->convertContextDefinitionAnnotation($value),
then
public function convertContextDefinitionAnnotation(DoctrineAnnotationTagValueNode $value): ?Node\Expr\New_ { // Check the annotation type, this will be helpful later. if ($value->identifierTypeNode->name !== '@ContextDefinition') { return null; } $valueArg = null; $argumentArg = null; $contextArg = null; // Loop through the values of the annotation, just to make 100% sure we have the correct argument order foreach ($value->values as $translateValue) { if ($translateValue->key === null) { $valueArg = $this->nodeFactory->createArg($translateValue->value->value); } if ($translateValue->key === 'context') { $contextArg = $this->nodeFactory->createArg(['context' => $translateValue->value->value]); } if ($translateValue->key === 'arguments') { $argumentArg = []; foreach ($translateValue->value->values as $argumentValue) { $argumentArg[$argumentValue->key->value] = $argumentValue->value->value; } $argumentArg = $this->nodeFactory->createArg($argumentArg); } } $argArray = []; if ($valueArg !== null) { $argArray[] = $valueArg; } if ($argumentArg !== null) { $argArray[] = $argumentArg; } if ($contextArg !== null) { $argArray[] = $contextArg; } return new Node\Expr\New_(new Node\Name('\Drupal\Core\Plugin\Context\ContextDefinition'), $argArray); }
- 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
^ Change above doesn't add the
\Drupal\Core\Plugin\Context\ContextDefinition
usage though :-( - 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
ah, we need to inspect the context definition. e.g. if it's "entity:x", needs to be a EntityContextDefinition, and then omit the "entity:" in the constructor. So it's not as straightforward as I thought.