You are here

PluginCollectionInterface.php in Extensible BBCode 8.3

Same filename and directory in other branches
  1. 4.0.x src/PluginCollectionInterface.php

Namespace

Drupal\xbbcode

File

src/PluginCollectionInterface.php
View source
<?php

namespace Drupal\xbbcode;

use ArrayAccess;
use Countable;
use IteratorAggregate;

/**
 * Common methods to access a plugin collection.
 *
 * This abstraction has the simple purpose of allowing functions to take both
 * an associative array of plugins and a full plugin collection instance.
 */
interface PluginCollectionInterface extends ArrayAccess, Countable, IteratorAggregate {

  /**
   * Determines if a plugin instance exists.
   *
   * @param string $instance_id
   *   The ID of the plugin instance to check.
   *
   * @return bool
   *   TRUE if the plugin instance exists, FALSE otherwise.
   */
  public function has($instance_id) : bool;

  /**
   * Gets a plugin instance, initializing it if necessary.
   *
   * @param string $instance_id
   *   The ID of the plugin instance being retrieved.
   */
  public function &get($instance_id);

  /**
   * Stores an initialized plugin.
   *
   * @param string $instance_id
   *   The ID of the plugin instance being stored.
   * @param mixed $value
   *   An instantiated plugin.
   */
  public function set($instance_id, $value);

  /**
   * Removes an initialized plugin.
   *
   * The plugin can still be used; it will be reinitialized.
   *
   * @param string $instance_id
   *   The ID of the plugin instance to remove.
   */
  public function remove($instance_id);

}

Interfaces

Namesort descending Description
PluginCollectionInterface Common methods to access a plugin collection.