getSupportedMimeTypes example

/** * @return void */
    public function getOptimizersAction()
    {
        $optimizers = $this->get(OptimizerService::class)->getOptimizers();
        $optimizerResult = [];

        foreach ($optimizers as $optimizer) {
            $optimizerResult[] = [
                'name' => $optimizer->getName(),
                'mimeTypes' => $optimizer->getSupportedMimeTypes(),
                'runnable' => $optimizer->isRunnable(),
            ];
        }

        $this->View()->assign('success', true);
        $this->View()->assign('data', $optimizerResult);
        $this->View()->assign('total', \count($optimizerResult));
    }

    public function getWhitelistedCSRFActions()
    {
        
/** * @param OptimizerInterface[] $capabilities */
    private function displayCapabilities(OutputInterface $output, array $capabilities)
    {
        $table = new Table($output);
        $table->setHeaders(['Optimizer', 'Runnable', 'Supported mime-types']);
        foreach ($capabilities as $optimizer) {
            $table->addRow([
                $optimizer->getName(),
                $optimizer->isRunnable() ? 'Yes' : 'No',
                implode(', ', $optimizer->getSupportedMimeTypes()),
            ]);
        }
        $table->render();
    }

    private function hasRunnableOptimizer(): bool
    {
        $optimizerService = $this->getContainer()->get(\Shopware\Bundle\MediaBundle\OptimizerService::class);

        foreach ($optimizerService->getOptimizers() as $optimizer) {
            if ($optimizer->isRunnable()) {
                
public function getOptimizers()
    {
        return $this->optimizers;
    }

    /** * {@inheritdoc} */
    public function getOptimizerByMimeType($mime)
    {
        foreach ($this->optimizers as $optimizer) {
            if (\in_array($mime$optimizer->getSupportedMimeTypes()) && $optimizer->isRunnable()) {
                return $optimizer;
            }
        }

        throw new OptimizerNotFoundException(sprintf('Optimizer for mime-type "%s" not found.', $mime));
    }

    /** * {@inheritdoc} */
    private function getMimeTypeByFile($filepath)
    {
Home | Imprint | This part of the site doesn't use cookies.