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