/** * {@inheritdoc} */ public function delete(MediaProviderInterface $provider, MediaInterface $media) { // delete the differents formats foreach ($provider->getFormats() as $format => $definition) { $path = $provider->generatePrivateUrl($media, $format); if ($provider->getFilesystem()->has($path)) { $provider->getFilesystem()->delete($path); } } }
/** * {@inheritdoc} */ public function delete(MediaProviderInterface $provider, MediaInterface $media, $formats = null) { if (is_null($formats)) { $formats = array_keys($provider->getFormats()); } elseif (is_string($formats)) { $formats = array($formats); } if (!is_array($formats)) { throw new \InvalidArgumentException('"Formats" argument should be string or array'); } foreach ($formats as $format) { $path = $provider->generatePrivateUrl($media, $format); if ($path && $provider->getFilesystem()->has($path)) { $provider->getFilesystem()->delete($path); } } }
/** * @param MediaProviderInterface $provider * @param string $context * * @return string */ public function getFormat(MediaProviderInterface $provider, $context) { $format = $this->input->getArgument('format'); if (null === $format) { $formats = array_keys($provider->getFormats()); $formats[] = '<ALL THUMBNAILS>'; $dialog = $this->getHelperSet()->get('dialog'); $formatKey = $dialog->select($this->output, 'Please select the format', $formats); $format = $formats[$formatKey]; if ($format === '<ALL THUMBNAILS>') { $format = $context . '_all'; } } else { $format = $context . '_' . $format; } return $format; }