Moves files between public and private file storage
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
856 B

<?php
namespace Drupal\media_file_privacy\Plugin\Action;
use Drupal\Core\Action\Attribute\Action;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\media\MediaInterface;
/**
* Moves private source files for published media to public storage.
*/
#[Action(
id: 'media_file_privacy_move_published_public',
label: new TranslatableMarkup('Move published media files to public storage'),
type: 'media',
)]
final class MovePublishedMediaFilePublic extends MediaFileMoveActionBase {
/**
* {@inheritdoc}
*/
protected function sourceScheme(): string {
return 'private';
}
/**
* {@inheritdoc}
*/
protected function destinationScheme(): string {
return 'public';
}
/**
* {@inheritdoc}
*/
protected function mediaStateMatches(MediaInterface $media): bool {
return $media->isPublished();
}
}