You are here

public function ScssCompilerService::__construct in SCSS/Less Compiler 8

Constructs a SCSS Compiler service object.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $config: The configuration object factory.

\Drupal\Core\Theme\ThemeManagerInterface $theme_manager: The theme manager.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler.

\Symfony\Component\HttpFoundation\RequestStack $request_stack: The request stack.

\Drupal\Core\Cache\CacheBackendInterface $cache: The default cache bin.

\Drupal\Core\File\FileSystemInterface $file_system: The file system service.

File

src/ScssCompilerService.php, line 139

Class

ScssCompilerService
Defines a class for scss compiler service.

Namespace

Drupal\scss_compiler

Code

public function __construct(ConfigFactoryInterface $config, ThemeManagerInterface $theme_manager, ModuleHandlerInterface $module_handler, RequestStack $request_stack, CacheBackendInterface $cache, FileSystemInterface $file_system) {
  $this->config = $config
    ->get('scss_compiler.settings');
  $this->themeManager = $theme_manager;
  $this->moduleHandler = $module_handler;
  $this->request = $request_stack
    ->getCurrentRequest();
  $this->cache = $cache;
  $this->fileSystem = $file_system;
  $this->activeThemeName = $theme_manager
    ->getActiveTheme()
    ->getName();
  $this->cacheFolder = self::CACHE_FOLDER;
  $this->isCacheEnabled = $this->config
    ->get('cache');
  $this->tokens = [
    '@drupal_root' => '',
  ];
  if (!$this
    ->isCacheEnabled() && $this->config
    ->get('check_modify_time')) {
    $this->lastModifyList = [];
    if ($cache = $this->cache
      ->get('scss_compiler_modify_list')) {
      $this->lastModifyList = $cache->data;
    }
  }

  // Since Drupal 9.1.4 calling a cache->set method in the class destructor
  // causes an error.
  if (!$this
    ->isCacheEnabled()) {
    register_shutdown_function([
      $this,
      'destroy',
    ]);
  }
}