You are here

interface TagPluginInterface in Extensible BBCode 8.3

Same name and namespace in other branches
  1. 4.0.x src/Plugin/TagPluginInterface.php \Drupal\xbbcode\Plugin\TagPluginInterface

Defines the interface for XBBCode tag plugins.

Hierarchy

Expanded class hierarchy of TagPluginInterface

All classes that implement TagPluginInterface

See also

TagPluginBase

XBBCodeTag

Plugin API

3 files declare their use of TagPluginInterface
TagPluginManager.php in src/TagPluginManager.php
TagSetForm.php in src/Form/TagSetForm.php
XBBCodeFilter.php in src/Plugin/Filter/XBBCodeFilter.php

File

src/Plugin/TagPluginInterface.php, line 17

Namespace

Drupal\xbbcode\Plugin
View source
interface TagPluginInterface extends TagProcessorInterface, PluginInspectionInterface {

  /**
   * Returns the status of this tag plugin.
   *
   * @return bool
   *   Plugin status.
   */
  public function status() : bool;

  /**
   * Returns the administrative label for this tag plugin.
   *
   * @return string
   *   Plugin label.
   */
  public function label() : string;

  /**
   * Returns the administrative description for this tag plugin.
   *
   * @return string
   *   Plugin description.
   */
  public function getDescription() : string;

  /**
   * Returns the configured name.
   *
   * @return string
   *   The tag name.
   */
  public function getName() : string;

  /**
   * Returns the default tag name.
   *
   * @return string
   *   Plugin default name.
   */
  public function getDefaultName() : string;

  /**
   * Return the unprocessed sample code.
   *
   * This should have {{ name }} placeholders for the tag name.
   *
   * @return string
   *   The sample code.
   */
  public function getDefaultSample() : string;

  /**
   * Return a sample tag for the filter tips.
   *
   * This sample should reference the configured tag name.
   *
   * @return string
   *   The sample code.
   */
  public function getSample() : string;

  /**
   * Generate output from a tag element.
   *
   * @param \Drupal\xbbcode\Parser\Tree\TagElementInterface $tag
   *   The tag element to process.
   *
   * @return \Drupal\xbbcode\Parser\Tree\OutputElementInterface
   *   Actually a TagProcessResult, but PHP does not support covariant types.
   *
   * @TODO: Add covariant type hints after PHP 7.4 is required.
   *
   * @see \Drupal\xbbcode\TagProcessResult
   */
  public function process(TagElementInterface $tag) : OutputElementInterface;

  /**
   * Transform an elements' content, to armor against other filters.
   *
   * - Use the inner content if all children will be rendered.
   *   (This just means the children's own ::prepare() functions are used.)
   * - Use $tag->getSource() if no children will be rendered.
   * - Traverse the tag's descendants for more complex cases.
   *
   * @param string $content
   *   The content, after applying inner transformations.
   * @param \Drupal\xbbcode\Parser\Tree\TagElementInterface $tag
   *   The original tag element.
   *
   * @return string
   *   The prepared output.
   */
  public function prepare(string $content, TagElementInterface $tag) : string;

}

Members

Namesort descending Modifiers Type Description Overrides
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2
TagPluginInterface::getDefaultName public function Returns the default tag name. 1
TagPluginInterface::getDefaultSample public function Return the unprocessed sample code. 1
TagPluginInterface::getDescription public function Returns the administrative description for this tag plugin. 1
TagPluginInterface::getName public function Returns the configured name. 1
TagPluginInterface::getSample public function Return a sample tag for the filter tips. 1
TagPluginInterface::label public function Returns the administrative label for this tag plugin. 1
TagPluginInterface::prepare public function Transform an elements' content, to armor against other filters. 1
TagPluginInterface::process public function Generate output from a tag element. Overrides TagProcessorInterface::process 1
TagPluginInterface::status public function Returns the status of this tag plugin. 1