You are here

class Sandwich in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/plugin_type_example/src/Annotation/Sandwich.php \Drupal\plugin_type_example\Annotation\Sandwich

Defines a Sandwich annotation object.

Provides an example of how to define a new annotation type for use in defining a plugin type. Demonstrates documenting the various properties that can be used in annotations for plugins of this type.

Note that the "@ Annotation" line below is required and should be the last line in the docblock. It's used for discovery of Annotation definitions.

Hierarchy

Expanded class hierarchy of Sandwich

See also

\Drupal\plugin_type_example\SandwichPluginManager

Plugin API

1 file declares its use of Sandwich
SandwichPluginManager.php in plugin_type_example/src/SandwichPluginManager.php
2 classes are annotated with Sandwich
ExampleHamSandwich in plugin_type_example/src/Plugin/Sandwich/ExampleHamSandwich.php
Provides a ham sandwich.
ExampleMeatballSandwich in plugin_type_example/src/Plugin/Sandwich/ExampleMeatballSandwich.php
Provides a meatball sandwich.

File

plugin_type_example/src/Annotation/Sandwich.php, line 22

Namespace

Drupal\plugin_type_example\Annotation
View source
class Sandwich extends Plugin {

  /**
   * A brief, human readable, description of the sandwich type.
   *
   * This property is designated as being translatable because it will appear
   * in the user interface. This provides a hint to other developers that they
   * should use the Translation() construct in their annotation when declaring
   * this property.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $description;

  /**
   * The number of calories per serving of this sandwich type.
   *
   * This property is a float value, so we indicate that to other developers
   * who are writing annotations for a Sandwich plugin.
   *
   * @var int
   */
  public $calories;

}

Members

Namesort descending Modifiers Type Description Overrides
Plugin::$definition protected property The plugin definition read from the class annotation. 1
Plugin::get public function Gets the value of an annotation. Overrides AnnotationInterface::get 5
Plugin::getClass public function Gets the class of the annotated class. Overrides AnnotationInterface::getClass
Plugin::getId public function Gets the unique ID for this annotated class. Overrides AnnotationInterface::getId
Plugin::getProvider public function Gets the name of the provider of the annotated class. Overrides AnnotationInterface::getProvider
Plugin::parse protected function Parses an annotation into its definition.
Plugin::setClass public function Sets the class of the annotated class. Overrides AnnotationInterface::setClass
Plugin::setProvider public function Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider
Plugin::__construct public function Constructs a Plugin object. 2
Sandwich::$calories public property The number of calories per serving of this sandwich type.
Sandwich::$description public property A brief, human readable, description of the sandwich type.