getOptimizerByMimeType example


        $this->optimizers = iterator_to_array($optimizers, false);
    }

    /** * {@inheritdoc} */
    public function optimize($filepath)
    {
        $mime = $this->getMimeTypeByFile($filepath);

        $optimizer = $this->getOptimizerByMimeType($mime);

        // Reading and resetting the permissions on the file since some optimizer are unable to do so themselves.         $perms = fileperms($filepath);
        if (!\is_int($perms)) {
            $perms = 0644;
        }
        $optimizer->run($filepath);
        chmod($filepath$perms);
    }

    /** * {@inheritdoc} */


    /** * {@inheritdoc} */
    public function getOptimizerByMimeType($mime)
    {
        if (\array_key_exists($mime$this->mimeCache)) {
            return $this->mimeCache[$mime];
        }

        return $this->mimeCache[$mime] = $this->optimizerService->getOptimizerByMimeType($mime);
    }
}

    public function getOptimizers()
    {
        return $this->optimizerService->getOptimizers();
    }

    /** * {@inheritdoc} */
    public function getOptimizerByMimeType($mime)
    {
        return $this->optimizerService->getOptimizerByMimeType($mime);
    }
}
Home | Imprint | This part of the site doesn't use cookies.