Use Drupal plugin system with OperationTypes
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3523046. --> Reported by: [valthebald](https://www.drupal.org/user/239562) >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>For different reasons (one of them to keep the abstraction layer intact and prevent creation of provider-specific operations), in AI 1.0.x/1.1.x operation types are not the same plugins that one would expect from a Drupal module.</p> <p>This was working mostly fine, especially after adding a workaround in <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/ai/issues/3500120" title="Status: Closed (fixed)">#3500120: Programmatically add OperationType in AiProviderPluginManager</a></span>, but the change in Drupal core <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/drupal/issues/3502913" title="Status: Closed (fixed)">#3502913: Add a fallback classloader that can handle missing traits for attribute discovery</a></span> has broken internal logic of using interfaces instead of classes for the operation types discovery.</p> <p><span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/ai/issues/3521877" title="Status: Closed (fixed)">#3521877: Not getting all operation types on AI Settings page</a></span> overcomes this change by using custom plugin discovery, but this looks "patchy"</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <p>It was proposed multiple times to use default Drupal plugin system for the operation types, maybe it is time to do so.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <p>* Write the patch<br> * Add the test that custom operation types are discoverable</p> <h3 id="summary-ui-changes">User interface changes</h3> <p>No UI changes</p> <h3 id="summary-api-changes">API changes</h3> <p>Contrib modules get "native" (not via alter hook) option to define their own operation types.</p> > Related issue: [Issue #3521877](https://www.drupal.org/node/3521877)
issue