48772cef3231780cac933f041d2f65cee0b2a438
[yaffs-website] / web / themes / contrib / bootstrap / src / Annotation / PluginCallback.php
1 <?php
2
3 namespace Drupal\bootstrap\Annotation;
4
5 use Drupal\bootstrap\Bootstrap;
6 use Drupal\Component\Annotation\AnnotationInterface;
7 use Drupal\Component\Annotation\PluginID;
8
9 /**
10  * Defines a Plugin annotation object that just contains an ID.
11  *
12  * @Annotation
13  *
14  * @ingroup utility
15  */
16 class PluginCallback extends PluginID {
17
18   /**
19    * The plugin ID.
20    *
21    * When an annotation is given no key, 'value' is assumed by Doctrine.
22    *
23    * @var string
24    */
25   public $value;
26
27   /**
28    * Flag that determines how to add the plugin to a callback array.
29    *
30    * @var \Drupal\bootstrap\Annotation\BootstrapConstant
31    *
32    * Must be one of the following constants:
33    *   - \Drupal\bootstrap\Bootstrap::CALLBACK_APPEND
34    *   - \Drupal\bootstrap\Bootstrap::CALLBACK_PREPEND
35    *   - \Drupal\bootstrap\Bootstrap::CALLBACK_REPLACE_APPEND
36    *   - \Drupal\bootstrap\Bootstrap::CALLBACK_REPLACE_PREPEND
37    * Use with @ BootstrapConstant annotation.
38    *
39    * @see \Drupal\bootstrap\Bootstrap::addCallback()
40    */
41   public $action = Bootstrap::CALLBACK_APPEND;
42
43   /**
44    * A callback to replace.
45    *
46    * @var string
47    */
48   public $replace = FALSE;
49
50   /**
51    * {@inheritdoc}
52    */
53   public function get() {
54     $definition = parent::get();
55     $parent_properties = array_keys($definition);
56     $parent_properties[] = 'value';
57
58     // Merge in the defined properties.
59     $reflection = new \ReflectionClass($this);
60     foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
61       $name = $property->getName();
62       if (in_array($name, $parent_properties)) {
63         continue;
64       }
65       $value = $property->getValue($this);
66       if ($value instanceof AnnotationInterface) {
67         $value = $value->get();
68       }
69       $definition[$name] = $value;
70     }
71
72     return $definition;
73   }
74
75 }