abstract class InstallablePlugin in Markdown 8.2
Base annotation for "installable" plugins.
Note: Doctrine doesn't support multiple types, so if the property accepts more than a single type, "mixed" must be used instead of the desired piped types.
@todo Move upstream to https://www.drupal.org/project/installable_plugins.
Hierarchy
- class \Drupal\Component\Annotation\AnnotationBase implements AnnotationInterface
- class \Drupal\markdown\Annotation\AnnotationObject implements \Drupal\markdown\Annotation\ArrayAccess, \Drupal\markdown\Annotation\IteratorAggregate, PluginDefinitionInterface uses DependencySerializationTrait
- class \Drupal\markdown\Annotation\InstallablePlugin uses InstallablePluginTrait
- class \Drupal\markdown\Annotation\AnnotationObject implements \Drupal\markdown\Annotation\ArrayAccess, \Drupal\markdown\Annotation\IteratorAggregate, PluginDefinitionInterface uses DependencySerializationTrait
Expanded class hierarchy of InstallablePlugin
See also
https://github.com/doctrine/annotations/issues/129
4 files declare their use of InstallablePlugin
- AllowedHtmlManager.php in src/
PluginManager/ AllowedHtmlManager.php - BaseExtension.php in src/
Plugin/ Markdown/ BaseExtension.php - ExtensionManager.php in src/
PluginManager/ ExtensionManager.php - InstallablePluginManager.php in src/
PluginManager/ InstallablePluginManager.php
File
- src/
Annotation/ InstallablePlugin.php, line 16
Namespace
Drupal\markdown\AnnotationView source
abstract class InstallablePlugin extends AnnotationObject {
use InstallablePluginTrait;
/**
* An array of available installable libraries this plugin supports.
*
* @var \Drupal\markdown\Annotation\InstallableLibrary[]
*/
public $libraries = [];
/**
* Retrieves the installed library or plugin identifier.
*
* @return string
* The installed identifier.
*/
public function getInstalledId() {
if (($installed = $this
->getInstalledLibrary()) && ($id = $installed
->getId())) {
return $id;
}
return $this
->getId();
}
/**
* Retrieves the installed library.
*
* @return \Drupal\markdown\Annotation\InstallableLibrary|void
* The installed library.
*/
public function getInstalledLibrary() {
return current(array_filter($this->libraries, function ($library) {
return !$library->requirementViolations;
})) ?: NULL;
}
/**
* Retrieves the preferred library.
*
* @return \Drupal\markdown\Annotation\InstallableLibrary|void
* The preferred library.
*/
public function getPreferredLibrary() {
return current(array_filter($this->libraries, function ($library) {
return $library->preferred;
}));
}
/**
* Retrieves requirements of a certain type.
*
* @param string $type
* The requirement type to limit by.
* @param string $id
* Optional. A specific identifier to limit by.
*
* @return \Drupal\markdown\Annotation\InstallableRequirement[]
* An array of requirements matching the type.
*/
public function getRequirementsByType($type, $id = NULL) {
$requirements = [];
foreach (array_merge($this->requirements, $this->runtimeRequirements) as $requirement) {
if (!$requirement instanceof InstallableRequirement) {
continue;
}
list($t, $i) = $requirement
->listTypeId();
if ($type === $t) {
if (isset($id) && $id !== $i) {
continue;
}
$requirements[] = $requirement;
}
}
return $requirements;
}
/**
* Retrieves requirements of a certain constraint type.
*
* @param string $name
* The requirement constraint name to limit by.
* @param mixed $value
* Optional. A specific value to limit by.
*
* @return \Drupal\markdown\Annotation\InstallableRequirement[]
* An array of requirements matching the type.
*/
public function getRequirementsByConstraint($name, $value = NULL) {
$requirements = [];
foreach (array_merge($this->requirements, $this->runtimeRequirements) as $requirement) {
if (!$requirement instanceof InstallableRequirement) {
continue;
}
foreach ($requirement->constraints as $k => $v) {
if ($k === $name) {
if (isset($value) && $value !== $v) {
continue;
}
$requirements[] = $requirement;
continue 2;
}
}
}
return $requirements;
}
/**
* Indicates whether plugin is installed.
*
* @return bool
* TRUE or FALSE
*/
public function isInstalled() {
return empty($this->requirementViolations);
}
/**
* Indicates whether the preferred library is installed.
*
* @return bool
* TRUE or FALSE
*/
public function isPreferredLibraryInstalled() {
return $this
->getPreferredLibrary() === $this
->getInstalledLibrary();
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AnnotationBase:: |
protected | property | The class used for this annotated class. | |
AnnotationBase:: |
public | property | The annotated class ID. | 1 |
AnnotationBase:: |
protected | property | The provider of the annotated class. | |
AnnotationBase:: |
public | function |
Gets the class of the annotated class. Overrides AnnotationInterface:: |
|
AnnotationBase:: |
public | function |
Gets the name of the provider of the annotated class. Overrides AnnotationInterface:: |
|
AnnotationBase:: |
public | function |
Sets the class of the annotated class. Overrides AnnotationInterface:: |
|
AnnotationBase:: |
public | function |
Sets the name of the provider of the annotated class. Overrides AnnotationInterface:: |
|
AnnotationObject:: |
public | property | The description of the plugin. | |
AnnotationObject:: |
public | property | A human-readable label. | |
AnnotationObject:: |
public | property | The weight of the plugin. | |
AnnotationObject:: |
protected | property | Stores deprecated values. | |
AnnotationObject:: |
protected | property | A list of deprecation messages, keyed by the deprecated property name. | |
AnnotationObject:: |
private | property | A list of triggered deprecations. | |
AnnotationObject:: |
public static | function | Allows the creation of new objects statically, for easier chainability. | |
AnnotationObject:: |
constant | |||
AnnotationObject:: |
protected | function | Merges values with this plugin. | |
AnnotationObject:: |
public | function |
Gets the value of an annotation. Overrides AnnotationInterface:: |
|
AnnotationObject:: |
public | function |
Gets the unique ID for this annotated class. Overrides AnnotationBase:: |
|
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
public | function |
Gets the unique identifier of the plugin. Overrides PluginDefinitionInterface:: |
|
AnnotationObject:: |
public | function | Merges values with this plugin. | |
AnnotationObject:: |
protected | function | Normalizes a value to ensure its ready to be merged with the definition. | |
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
protected | function | Indicates properties that should never be overridden after instantiation. | 1 |
AnnotationObject:: |
private | function | Triggers a deprecation notice for a given property. | |
AnnotationObject:: |
protected | function | Helper method for validating the definition identifier. | 2 |
AnnotationObject:: |
public | function | AnnotationObject constructor. | 1 |
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
public | function | ||
AnnotationObject:: |
public | function | ||
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | Aliased as: __sleepTrait | 1 |
DependencySerializationTrait:: |
public | function | Aliased as: __wakeupTrait | 2 |
InstallablePlugin:: |
public | property | An array of available installable libraries this plugin supports. | |
InstallablePlugin:: |
public | function | Retrieves the installed library or plugin identifier. | |
InstallablePlugin:: |
public | function | Retrieves the installed library. | |
InstallablePlugin:: |
public | function | Retrieves the preferred library. | |
InstallablePlugin:: |
public | function | Retrieves requirements of a certain constraint type. | |
InstallablePlugin:: |
public | function | Retrieves requirements of a certain type. | |
InstallablePlugin:: |
public | function | Indicates whether plugin is installed. | |
InstallablePlugin:: |
public | function | Indicates whether the preferred library is installed. | |
InstallablePluginTrait:: |
public | property | Indicates the plugin has been deprecated by providing a message. | |
InstallablePluginTrait:: |
public | property | Indicates the plugin is experimental by providing a message. | |
InstallablePluginTrait:: |
public | property | Flag indicating whether plugin is installed. | |
InstallablePluginTrait:: |
public | property | The class name of the primary object that is implemented by the library. | |
InstallablePluginTrait:: |
public | property | Flag indicating whether it is the preferred library. | |
InstallablePluginTrait:: |
public | property | An array of requirements for the plugin. | |
InstallablePluginTrait:: |
public | property | A list of requirement violation messages. | |
InstallablePluginTrait:: |
public | property | An array of runtime requirements for the plugin. | |
InstallablePluginTrait:: |
public | property | Flag indicating whether this plugin is to be visible in UI areas. | |
InstallablePluginTrait:: |
public | property | A URL for the plugin, typically for installation instructions. | |
InstallablePluginTrait:: |
public | property | The installed version. | |
InstallablePluginTrait:: |
public | property | The constraint the version must satisfy to be considered "installable". | |
InstallablePluginTrait:: |
public | function | Retrieves the plugin as a link using its label and URL. | |
InstallablePluginTrait:: |
public | function | Retrieves the definition's URL property as an object. | 1 |
InstallablePluginTrait:: |
public | function | Retrieves requirements that contain "Version" constraints. | |
InstallablePluginTrait:: |
public | function | Validates the plugin requirements. |