reviewer-1.2.x-dev/src/Attribute/Task.php

src/Attribute/Task.php
<?php

declare(strict_types=1);

namespace Drupal\reviewer\Attribute;

/**
 * Attribute definition for tasks.
 */
#[\Attribute(\Attribute::TARGET_CLASS)]
final readonly class Task {

  /**
   * A task contains logic for checking, and optionally fixing, configuration.
   *
   * @param ?string $id
   *   The task ID. Tasks must have an ID, but can inherit from other tasks, so
   *   the ID does not need to be required. Attempting to use a task without an
   *   ID will throw an exception.
   * @param string[] $module_dependencies
   *   List modules required for the task to run. If any of the modules listed
   *   are not enabled, the task will be skipped.
   */
  public function __construct(
    private ?string $id = NULL,
    private array $module_dependencies = [],
  ) {}

  /**
   * Get the task ID.
   *
   * @throws \InvalidArgumentException
   *   Thrown when the task ID is empty.
   */
  public function getId(): string {
    return $this->id ?? throw new \InvalidArgumentException('Task ID must not be empty.');
  }

  /**
   * Get the module dependencies.
   *
   * @return string[]
   */
  public function getModuleDependencies(): array {
    return $this->module_dependencies;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc