
| Current Path : /var/www/html/wirtschaftsclub.web-klick.de/themes/bootstrap/src/Annotation/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/wirtschaftsclub.web-klick.de/themes/bootstrap/src/Annotation/BootstrapConstant.php |
<?php
namespace Drupal\bootstrap\Annotation;
use Doctrine\Common\Annotations\AnnotationException;
use Drupal\Component\Annotation\AnnotationBase;
/**
* Defines a BootstrapConstant annotation object.
*
* @Annotation
*
* @ingroup utility
*/
class BootstrapConstant extends AnnotationBase {
/**
* The stored constant value.
*
* @var mixed
*/
protected $value;
/**
* {@inheritdoc}
*/
public function __construct(array $values) {
$string = $values['value'];
// Handle classes.
if (strpos($string, '::') !== FALSE) {
list($class, $constant) = explode('::', $string);
try {
$reflection = new \ReflectionClass($class);
if ($reflection->hasConstant($constant)) {
$this->value = $reflection->getConstant($constant);
return;
}
}
catch (\ReflectionException $e) {
}
}
// Handle procedural constants.
if (!$this->value && defined($string)) {
$this->value = constant($string);
return;
}
throw AnnotationException::semanticalErrorConstants($this->value);
}
/**
* {@inheritdoc}
*/
public function get() {
return $this->value;
}
}