You are here

public function AssetOptimizer::__construct in Advanced CSS/JS Aggregation 8.3

Same name and namespace in other branches
  1. 8.4 src/Asset/AssetOptimizer.php \Drupal\advagg\Asset\AssetOptimizer::__construct()

Constructs the Optimizer object.

Parameters

\Drupal\Core\Config\ConfigFactoryInterface $config_factory: A config factory for retrieving required config objects.

\Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher: The event dispatcher.

\Drupal\Core\Cache\CacheBackendInterface $cache: The AdvAgg cache.

2 calls to AssetOptimizer::__construct()
CssOptimizer::__construct in src/Asset/CssOptimizer.php
Constructs the Optimizer object.
JsOptimizer::__construct in src/Asset/JsOptimizer.php
Constructs the Optimizer object.
2 methods override AssetOptimizer::__construct()
CssOptimizer::__construct in src/Asset/CssOptimizer.php
Constructs the Optimizer object.
JsOptimizer::__construct in src/Asset/JsOptimizer.php
Constructs the Optimizer object.

File

src/Asset/AssetOptimizer.php, line 103

Class

AssetOptimizer
Defines the base AdvAgg optimizer.

Namespace

Drupal\advagg\Asset

Code

public function __construct(ConfigFactoryInterface $config_factory, ContainerAwareEventDispatcher $event_dispatcher, CacheBackendInterface $cache) {
  $this->config = $config_factory
    ->get('advagg.settings');
  $this->eventDispatcher = $event_dispatcher;
  $this->cache = $cache;
  $this->dnsPrefetch = [];
  $this->cacheLevel = $this->config
    ->get('cache_level');
  $this->fixType = $this->config
    ->get("{$this->extension}.fix_type");
  if ($this->fixType) {
    $this->basePath = substr($GLOBALS['base_root'] . $GLOBALS['base_path'], strpos($GLOBALS['base_root'] . $GLOBALS['base_path'], '//') + 2);
    $this->basePathLen = strlen($this->basePath);
  }
  $this->gZip = $this
    ->shouldGZip();
  $this->brotli = $this
    ->shouldBrotli();
}