AiAgents do not extend \Drupal\Core\Plugin\PluginBase

Created on 25 September 2024, about 2 months ago

AiAgents plugins extend the AiAgentBase which is defined as:

abstract class AiAgentBase implements AiAgentInterface {...}

I'm wondering if there is a reason why the AiAgentBase does not extend drupal's \Drupal\Core\Plugin\PluginBase.

I'm also wondering why the services are not always injected using a create() method like the webform agent does:

  /**
   * {@inheritDoc}
   */
  public function __construct(
    ExtensionPathResolver $extensionPathResolver,
    EntityTypeManagerInterface $entityTypeManager,
    WebformActions $webformActions
  ) {
    parent::__construct();
    $this->entityTypeManager = $entityTypeManager;
    $this->webformActions = $webformActions;
    $this->baseYaml = Yaml::parse(file_get_contents($extensionPathResolver->getPath('module', 'ai_agents') . '/resources/webform_example.yml'));
    $this->exampleYaml = Yaml::parse(file_get_contents($extensionPathResolver->getPath('module', 'ai_agents') . '/resources/webform_example.yml'));
  }

  /**
   * {@inheritDoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static(
      $container->get('extension.path.resolver'),
      $container->get('entity_type.manager'),
      $container->get('ai_agents.webform_actions')
    );
  }
📌 Task
Status

Needs work

Version

1.0

Component

Code

Created by

🇩🇪Germany Harlor Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024