You are here

public function Theme::__construct in Express 8

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.

1 call to Theme::__construct()
Theme::__wakeup in themes/contrib/bootstrap/src/Theme.php
Unserialize method.

File

themes/contrib/bootstrap/src/Theme.php, line 152
Contains \Drupal\bootstrap.

Class

Theme
Defines a theme object.

Namespace

Drupal\bootstrap

Code

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';
    }
    else {
      if (is_int($livereload)) {
        $livereload = "//127.0.0.1:{$livereload}/livereload.js";
      }
      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
    }
  }
}