transmuter-1.0.0-alpha2/src/Attribute/Transmuter.php

src/Attribute/Transmuter.php
<?php

namespace Drupal\transmuter\Attribute;

use Drupal\transmuter\Plugin\TransmuterDefinition;
use Drupal\themespace\Attribute\ProviderTypedPlugin;

/**
 * Definition attribute for transmuter plugins.
 */
#[\Attribute(\Attribute::TARGET_CLASS)]
class Transmuter extends ProviderTypedPlugin {

  /**
   * Constructs a new instance of the Transmuter plugin attribute.
   *
   * @param string $id
   *   The transmuter plugin identifier.
   * @param string|string[] $hook
   *   Either a single preprocess hook name or an array of preprocess hooks.
   * @param int $priority
   *   The hook priority of the transmuter. Smaller numbers will execute the
   *   same hook sooner than priorities that are larger numbers. Normal hook
   *   specificity rules still supercede this priority. It only applies to
   *   resolving the order of the same hook.
   * @param string|null $baseHook
   *   The base theme hook to ensure that this theme hook includes if the
   *   hook needs to be generated. The default behavior is to use the closest
   *   hook with the '__' used as the separator between theme suggestion parts.
   *   This hook is only used to create a hook suggestion if the theme registry
   *   has not already created one.
   * @param class-string|null $deriver
   *   The plugin deriver for deriving transmuter plugin definitions.
   */
  public function __construct(
    public readonly string $id,
    public readonly string|array $hook,
    public readonly ?int $priority = 0,
    public readonly ?string $baseHook = NULL,
    public readonly ?string $deriver = NULL,
  ) {}

  /**
   * Get the base theme hook to use when generating new theme hooks.
   *
   * @return string|null
   *   The base hook to use when this theme hook needs to be created.
   *
   * @see ::__construct()
   * @see \Drupal\transmuter\ThemeRegistryBuilder::doAlter()
   */
  public function getBaseHook(): ?string {
    return $this->baseHook;
  }

  /**
   * {@inheritdoc}
   *
   * @return \Drupal\transmuter\Plugin\TransmuterDefinition
   *   The transmuter plugin definition instance.
   */
  public function get(): TransmuterDefinition {
    return new TransmuterDefinition(parent::get());
  }

}

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

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