AlbumFactory.php
3 days ago
AlternateTextFactory.php
3 days ago
ArtistFactory.php
3 days ago
AudioPlayerFactory.php
3 days ago
AvailableSizesFactory.php
3 days ago
CaptionFactory.php
3 days ago
DimensionsFactory.php
3 days ago
DownloadFactory.php
3 days ago
ExifDataFactory.php
3 days ago
FileMetaAudioFactory.php
3 days ago
FileMetaVideoFactory.php
3 days ago
FileNameFactory.php
3 days ago
FileSizeFactory.php
3 days ago
FullPathFactory.php
3 days ago
HeightFactory.php
3 days ago
ImageFactory.php
3 days ago
MimeTypeFactory.php
3 days ago
PreviewFactory.php
3 days ago
VideoPlayerFactory.php
3 days ago
WidthFactory.php
3 days ago
VideoPlayerFactory.php
72 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\ColumnFactory\Media; |
| 6 | |
| 7 | use AC; |
| 8 | use AC\Column\BaseColumnFactory; |
| 9 | use AC\FormatterCollection; |
| 10 | use AC\Setting\ComponentCollection; |
| 11 | use AC\Setting\ComponentFactory\VideoDisplay; |
| 12 | use AC\Setting\Config; |
| 13 | use AC\Setting\DefaultSettingsBuilder; |
| 14 | use AC\Value\Extended\MediaPreview; |
| 15 | |
| 16 | class VideoPlayerFactory extends BaseColumnFactory |
| 17 | { |
| 18 | private VideoDisplay $video_display; |
| 19 | |
| 20 | public function __construct( |
| 21 | DefaultSettingsBuilder $default_settings_builder, |
| 22 | VideoDisplay $video_display |
| 23 | ) { |
| 24 | parent::__construct($default_settings_builder); |
| 25 | |
| 26 | $this->video_display = $video_display; |
| 27 | } |
| 28 | |
| 29 | protected function get_settings(Config $config): ComponentCollection |
| 30 | { |
| 31 | return new ComponentCollection([ |
| 32 | $this->video_display->create($config), |
| 33 | ]); |
| 34 | } |
| 35 | |
| 36 | protected function get_group(): ?string |
| 37 | { |
| 38 | return 'media-video'; |
| 39 | } |
| 40 | |
| 41 | public function get_column_type(): string |
| 42 | { |
| 43 | return 'column-video_player'; |
| 44 | } |
| 45 | |
| 46 | public function get_label(): string |
| 47 | { |
| 48 | return __('Video Player', 'codepress-admin-columns'); |
| 49 | } |
| 50 | |
| 51 | protected function get_formatters(Config $config): FormatterCollection |
| 52 | { |
| 53 | $formatters = new FormatterCollection([ |
| 54 | new AC\Formatter\Media\Video\ValidMimeType(), |
| 55 | new AC\Formatter\Media\AttachmentUrl(), |
| 56 | ]); |
| 57 | |
| 58 | if ($config->get('video_display', '') === 'embed') { |
| 59 | $formatters->add(new AC\Formatter\Media\VideoEmbed()); |
| 60 | } else { |
| 61 | $formatters->add( |
| 62 | new AC\Formatter\Media\Video\ModalEmbedLink( |
| 63 | new MediaPreview() |
| 64 | ) |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | return $formatters; |
| 69 | } |
| 70 | |
| 71 | } |
| 72 |