function public function Theme::__construct

8.x-3.x Theme.php public Theme::__construct(Extension $theme, ThemeHandlerInterface $theme_handler)

Theme constructor.

Parameters

\Drupal\Core\Extension\Extension $theme: A theme \Drupal\Core\Extension\Extension object.

\Drupal\Core\Extension\ThemeHandlerInterface $theme_handler: The theme handler object.

Class

Theme
Defines a theme object.

Namespace

Drupal\bootstrap

Source src/Theme.php (line 162)

public function __construct(Extension $theme, ThemeHandlerInterface $theme_handler) {
  // Determine if "development mode" is set.
  $this->dev = !!Settings::get('theme.dev');

  // Determine the URL for livereload, if set.
  $this->livereload = '';
  if ($livereload = Settings::get('theme.livereload')) {
    // If TRUE, then set the port to the default used by grunt-contrib-watch.
    if ($livereload === TRUE) {
      $livereload = '//127.0.0.1:35729/livereload.js';
    }
    // If an integer, assume it's a port.
    elseif (is_int($livereload)) {
      $livereload = "//127.0.0.1:$livereload/livereload.js";
    }
    // If it's scalar, attempt to parse the URL.
    elseif (is_scalar($livereload)) {
      try {
        $livereload = Url::fromUri($livereload)->toString();
      }
      catch (\Exception $e) {
        $livereload = '';
      }
    }

    // Typecast livereload URL to a string.
    $this->livereload = "$livereload" ? : '';
  }

  $this->name = $theme->getName();
  $this->theme = $theme;
  $this->themeHandler = $theme_handler;
  $this->themes = $this->themeHandler->listInfo();
  $this->info = isset($this->themes[$this->name]->info) ? $this->themes[$this->name]->info : [];
  $this->bootstrap = $this->subthemeOf('bootstrap');

  // Only install the theme if it's Bootstrap based and there are no schemas
  // currently set.
  if ($this->isBootstrap() && !$this->getSetting('schemas')) {
    try {
      $this->install();
    }
    catch (\Exception $e) {
      // Intentionally left blank.
      // @see https://www.drupal.org/node/2697075
    }
  }
}