Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Collection/VideoProviderCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getClassByVideoProvider(string $provider): string
return $this->bundleConfig['video_provider'][$provider]['class'];
}

throw new \Exception('No configuration exists for given provider.');
throw new \Exception('No configuration exists for given provider');
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/DependencyInjection/HeimrichHannotVideoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
namespace HeimrichHannot\VideoBundle\DependencyInjection;

use HeimrichHannot\VideoBundle\Video\FileVideo;
use HeimrichHannot\VideoBundle\Video\FileVideoMultipleResolution;
use HeimrichHannot\VideoBundle\Video\RemoteFileVideoMultipleResolution;
use HeimrichHannot\VideoBundle\Video\VimeoVideo;
use HeimrichHannot\VideoBundle\Video\YouTubeVideo;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -38,6 +40,14 @@ public function load(array $configs, ContainerBuilder $container)
$config['video_provider']['file']['class'] = FileVideo::class;
}

if(!isset($config['video_provider']['file_multi'])) {
$config['video_provider']['file_multi']['class'] = FileVideoMultipleResolution::class;
}

if(!isset($config['video_provider']['remote_file_multi'])) {
$config['video_provider']['remote_file_multi']['class'] = RemoteFileVideoMultipleResolution::class;
}

// Support deperecated option
// @todo: remove in version 1.0
$config['videoProvider'] = $config['video_provider'];
Expand Down
29 changes: 29 additions & 0 deletions src/EventListener/Dca/ValidateMultipleResolutionFileNames.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace HeimrichHannot\VideoBundle\EventListener\Dca;

use Contao\CoreBundle\ServiceAnnotation\Callback;
use Contao\DataContainer;
use Contao\StringUtil;
use Contao\System;
use HeimrichHannot\VideoBundle\Video\FileVideoMultipleResolution;
use HeimrichHannot\UtilsBundle\Model\ModelUtil;

/**
* @Callback(table="tl_content", target="fields.multiResolutionVideoSRC.save")
*/
class ValidateMultipleResolutionFileNames
{
public function __invoke($value, DataContainer $dc)
{
$files = StringUtil::deserialize($value);
foreach($files as $file) {
$fileObject = System::getContainer()->get(ModelUtil::class)->getModelInstanceIfId($file, 'tl_files');
if(!preg_match(FileVideoMultipleResolution::getFilePathRegExp(), $fileObject->path)) {
throw new \Exception("File name didn't match expectations, expected for example: file_name_720.mp4");
}
}

return $value;
}
}
43 changes: 42 additions & 1 deletion src/Generator/DcaFieldGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Contao\Controller;
use HeimrichHannot\VideoBundle\EventListener\Dca\ModifiyVideoPaletteListener;
use HeimrichHannot\VideoBundle\Video\RemoteFileVideoMultipleResolution;

class DcaFieldGenerator
{
Expand Down Expand Up @@ -81,7 +82,7 @@ public static function getVideoFields(array $dca = [])
return \Contao\System::getContainer()->get(\HeimrichHannot\VideoBundle\Collection\VideoProviderCollection::class)->getVideoProvider();
},
'reference' => &$GLOBALS['TL_LANG']['tl_content']['reference']['videoProvider'],
'eval' => ['submitOnChange' => true, 'maxlength' => 64, 'tl_class' => 'w50', 'includeBlankOption' => true],
'eval' => ['submitOnChange' => true, 'maxlength' => 64, 'includeBlankOption' => true],
'sql' => "varchar(64) NOT NULL default ''",
],
'addPreviewImage' => [
Expand Down Expand Up @@ -204,6 +205,46 @@ public static function getVideoFields(array $dca = [])
],
'sql' => 'blob NULL',
],
'multiResolutionVideoSRC' => [
'label' => &$GLOBALS['TL_LANG']['tl_content']['multiResolutionVideoSRC_file'],
'inputType' => 'fileTree',
'eval' => [
'multiple' => true,
'filesOnly' => true,
'fieldType' => 'checkbox',
'mandatory' => true,
'submitOnChange' => true,
'groupStyle' => 'width: 48%'
],
'sql' => 'blob NULL',
],
'videoRemoteFile' => [
'label' => &$GLOBALS['TL_LANG']['tl_content']['videoRemoteFile'],
'exclude' => false,
'inputType' => 'text',
'eval' => [
'maxlength' => 255,
'tl_class' => 'w50',
'mandatory' => true,
'rgxp' => 'custom',
'customRgxp' => RemoteFileVideoMultipleResolution::getFilePathRegExp()
],
'sql' => "varchar(255) NOT NULL default ''",
],
'videoRemoteResolutions' => [
'label' => &$GLOBALS['TL_LANG']['tl_content']['videoRemoteResolutions'],
'exclude' => false,
'inputType' => 'text',
'default' => '1080,720,480,360',
'eval' => [
'maxlength' => 255,
'tl_class' => 'w50 clr',
'mandatory' => true,
'rgxp' => 'custom',
'customRgxp' => RemoteFileVideoMultipleResolution::getResolutionsRegExp()
],
'sql' => "varchar(255) NOT NULL default ''",
],
'videoSubtitles' => [
'label' => &$GLOBALS['TL_LANG']['tl_content']['videoSubtitles'],
'exclude' => false,
Expand Down
Loading