Same name in other branches
  1. 6.0.x src/Asset/AssetOptimizer.php \Drupal\advagg\Asset\AssetOptimizer::__construct()
  2. 8.x-3.x src/Asset/AssetOptimizer.php \Drupal\advagg\Asset\AssetOptimizer::__construct()
  3. 8.x-4.x 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 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 125

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->fileSystem = \Drupal::service('file_system');
    $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();
}