You are here

class BootstrapConstant in Express 8

Defines a BootstrapConstant annotation object.

Hierarchy

Expanded class hierarchy of BootstrapConstant

2 files declare their use of BootstrapConstant
CdnJsdelivrVersion.php in themes/contrib/bootstrap/src/Plugin/Setting/Advanced/Cdn/CdnJsdelivrVersion.php
Contains \Drupal\bootstrap\Plugin\Setting\Advanced\Cdn\CdnJsdelivrVersion.
Link.php in themes/contrib/bootstrap/src/Plugin/Prerender/Link.php
Contains \Drupal\bootstrap\Plugin\Prerender\Link.

File

themes/contrib/bootstrap/src/Annotation/BootstrapConstant.php, line 19
Contains \Drupal\bootstrap\Annotation\BootstrapConstant.

Namespace

Drupal\bootstrap\Annotation
View 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

Namesort descending Modifiers Type Description Overrides
AnnotationBase::$class protected property The class used for this annotated class.
AnnotationBase::$id public property The annotated class ID. 1
AnnotationBase::$provider protected property The provider of the annotated class.
AnnotationBase::getClass public function Gets the class of the annotated class. Overrides AnnotationInterface::getClass
AnnotationBase::getId public function Gets the unique ID for this annotated class. Overrides AnnotationInterface::getId 1
AnnotationBase::getProvider public function Gets the name of the provider of the annotated class. Overrides AnnotationInterface::getProvider
AnnotationBase::setClass public function Sets the class of the annotated class. Overrides AnnotationInterface::setClass
AnnotationBase::setProvider public function Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider
BootstrapConstant::$value protected property The stored constant value.
BootstrapConstant::get public function Gets the value of an annotation. Overrides AnnotationInterface::get
BootstrapConstant::__construct public function