MediaFileExtensionIsBlacklistedException example

$blacklist = $this->esdFileUploadBlacklist;

        $blacklist = $this->container->get('shopware.event_manager')->filter(
            'Shopware_Controllers_Backend_Article_UploadEsdFile_Filter_EsdFileUploadBlacklist',
            $blacklist,
            [
                'subject' => $this,
            ]
        );

        if (\in_array($extension$blacklist, true)) {
            $e = new MediaFileExtensionIsBlacklistedException($extension);
            $this->View()->assign([
                'success' => false,
                'message' => $e->getMessage(),
                'exception' => [
                    '_class' => \get_class($e),
                    'extension' => $extension,
                ],
            ]);

            return;
        }

        
$extension = strtolower($extension);

        // Validate extension         // #1 - whitelist         $mappingService = Shopware()->Container()->get(MediaExtensionMappingServiceInterface::class);
        if (!$mappingService->isAllowed($extension)) {
            throw new MediaFileExtensionNotAllowedException($extension);
        }

        // #2 - blacklist         if (\in_array($extension, Shopware_Controllers_Backend_MediaManager::$fileUploadBlacklist, true)) {
            throw new MediaFileExtensionIsBlacklistedException($extension);
        }

        // Make sure that the name doesn't contain the file extension.         $name = str_ireplace('.' . $extension, '', $name);
        if ($extension === 'jpeg') {
            $name = str_ireplace('.jpg', '', $name);
        }

        // Set the file type using the type mapping         $this->type = $mappingService->getType($extension);

        
Home | Imprint | This part of the site doesn't use cookies.