class BootstrapConstant

Defines a BootstrapConstant annotation object.

Hierarchy

  • class \Drupal\bootstrap\Annotation\BootstrapConstant extends \Drupal\Component\Annotation\AnnotationBase

Expanded class hierarchy of BootstrapConstant

Related topics

2 files declare their use of BootstrapConstant

Namespace

Drupal\bootstrap\Annotation
Source
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;
  }

}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
BootstrapConstant::$value protected property The stored constant value.
BootstrapConstant::get public function
BootstrapConstant::__construct public function