You are here

public static function ScssphpCompiler::getStatus in SCSS/Less Compiler 8

Returns status of compiler library.

Return value

string|bool TRUE if library installed or string with error message.

Overrides ScssCompilerPluginInterface::getStatus

1 call to ScssphpCompiler::getStatus()
ScssphpCompiler::init in src/Plugin/ScssCompiler/ScssphpCompiler.php
Calls a code on plugin initialization.

File

src/Plugin/ScssCompiler/ScssphpCompiler.php, line 61

Class

ScssphpCompiler
Plugin implementation of the Scss compiler.

Namespace

Drupal\scss_compiler\Plugin\ScssCompiler

Code

public static function getStatus() {
  $compiler_class_exists = class_exists('ScssPhp\\ScssPhp\\Compiler');
  if (!$compiler_class_exists && !file_exists(DRUPAL_ROOT . '/libraries/scssphp/scss.inc.php')) {
    return t('ScssPhp Compiler library not found. Install it via composer "composer require scssphp/scssphp"');
  }

  // If library didn't autoload from the vendor folder, load it from the
  // libraries folder.
  if (!$compiler_class_exists) {
    require_once DRUPAL_ROOT . '/libraries/scssphp/scss.inc.php';

    // leafo/scssphp no longer supported, it was forked to
    // scssphp/scssphp.
    // @see https://github.com/leafo/scssphp/issues/707
    if (!class_exists('ScssPhp\\ScssPhp\\Compiler')) {
      $error_message = t('leafo/scssphp no longer supported. Update compiler library to scssphp/scssphp @url', [
        '@url' => '(https://github.com/scssphp/scssphp/releases)',
      ]);
    }
  }
  if (!empty($error_message)) {
    return $error_message;
  }
  return TRUE;
}