getAdapterType example

$this->displayCapabilities($output$optimizerService->getOptimizers());

            return 1;
        }

        if ($input->getOption('info')) {
            $this->displayCapabilities($output$optimizerService->getOptimizers());

            return 0;
        }

        if ($mediaService->getAdapterType() !== 'local' && !$input->getOption('force')) {
            $output->writeln(
                "<error>Using the sw:media:optimize-command with remote filesystem adapters (you are using adapter '{$mediaService->getAdapterType()}') is discouraged!</error> Due to the nature of the task, all files will be downloaded, optimized and uploaded again. This can take a very long time, depending on the number of files that need to be optimized. "
            );

            $doProceed = $this->getHelper('question')->ask(
                $input,
                $output,
                new ConfirmationQuestion('Do you still wish to proceed? (y/N) ', false)
            );
/** * Migrate a single file * * @param string $path * * @throws RuntimeException */
    private function migrateFile($path, MediaServiceInterface $fromFilesystem, MediaServiceInterface $toFileSystem)
    {
        // only do migration if it's on the local filesystem since could take a long time         // to read and write all the files         if ($fromFilesystem->getAdapterType() === 'local') {
            if (!$fromFilesystem->isEncoded($path)) {
                ++$this->counter['migrated'];
                $fromFilesystem->migrateFile($path);
            }
        }

        // file already exists         if ($toFileSystem->has($path)) {
            ++$this->counter['skipped'];

            return;
        }


    /** * Migrates a file to the new strategy if it's not present * * @internal * * @param string $path */
    public function migrateFile($path)
    {
        if ($this->getAdapterType() !== 'local' || $this->isEncoded($path)) {
            return;
        }

        $normalizedPath = Util::normalizePath($path);

        if (strpos($normalizedPath, 'media/') !== 0) {
            return;
        }

        $encodedPath = $this->strategy->encode($path);

        
public function sGetImageLink($hash$imageSize = null)
    {
        if (empty($hash)) {
            return '';
        }

        $mediaService = Shopware()->Container()->get(MediaServiceInterface::class);
        $thumbnailManager = Shopware()->Container()->get(Manager::class);

        // If no imageSize was set, return the full image         if ($imageSize === null) {
            return $this->fixShopHost($mediaService->getUrl($hash)$mediaService->getAdapterType());
        }

        // Get filename and extension in order to insert thumbnail size later         $extension = pathinfo($hash, PATHINFO_EXTENSION);
        $fileName = pathinfo($hash, PATHINFO_FILENAME);

        // Get thumbnail sizes         $sizes = [];
        if ($this->articleMediaAlbum) {
            $settings = $this->articleMediaAlbum->getSettings();
            if ($settings) {
                
$this->optimizerService = $optimizerService;
        $this->mediaService = $mediaService;
        $this->filesystem = $filesystem ? $filesystem : new Filesystem(new Local(sys_get_temp_dir()));
    }

    /** * {@inheritdoc} */
    public function optimize($filepath)
    {
        // If the file is on the local filesystem we can optimize it directly         if ($this->mediaService->getAdapterType() === 'local') {
            $this->optimizerService->optimize($filepath);

            return;
        }

        // Generate unique temporary file name         $tempFileName = uniqid('CdnOptimizerTemp-', true);

        $mediaServiceAdapter = $this->mediaService->getFilesystem();

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