Beispiel #1
0
 /**
  * Transform content and/or content type for the specified preprocessing chain object
  *
  * @param PreProcessor\Chain $chain
  * @return void
  */
 public function process(PreProcessor\Chain $chain)
 {
     if ($this->minification->isEnabled(pathinfo($chain->getTargetAssetPath(), PATHINFO_EXTENSION)) && $this->minification->isMinifiedFilename($chain->getTargetAssetPath()) && !$this->minification->isMinifiedFilename($chain->getOrigAssetPath())) {
         $content = $this->adapter->minify($chain->getContent());
         $chain->setContent($content);
     }
 }
Beispiel #2
0
    /**
     * Get path of file after using fallback rules
     *
     * @param string $type
     * @param string $file
     * @param string|null $area
     * @param ThemeInterface|null $theme
     * @param string|null $locale
     * @param string|null $module
     * @return string|false
     */
    private function resolveJsMinification(
        $type,
        $file,
        $area = null,
        ThemeInterface $theme = null,
        $locale = null,
        $module = null
    ) {
        $path = $this->fallback->resolve($type, $file, $area, $theme, $locale, $module);

        /**
         * Minified version as priority one
         */
        if ($path && $this->minification->isMinifiedFilename($path)) {
            return $path;
        }

        /**
         * If minification is disabled - return already found path
         */
        if (!$this->minification->isEnabled('js')) {
            return $path;
        }

        /**
         * Try to find minified version of file,
         * or return already found path
         */
        return $this->fallback->resolve(
            $type,
            $this->minification->addMinifiedSign($file),
            $area,
            $theme,
            $locale,
            $module
        ) ?: $path;
    }
 /**
  * @param string $filename
  * @param bool $result
  * @return void
  * @dataProvider isMinifiedFilenameDataProvider
  */
 public function testIsMinifiedFilename($filename, $result)
 {
     $this->assertEquals($result, $this->minification->isMinifiedFilename($filename));
 }