Skip to content

Commit

Permalink
see cl 3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Patzer committed Jan 23, 2019
1 parent 21bb099 commit 9d8d79e
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 60 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
@@ -1,7 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.

## [3.1.1] - 2018-01-15
## [3.1.2] - 2019-01-23

#### Fixed
- issue https://github.com/heimrichhannot/contao-youtube-bundle/issues/2

## [3.1.1] - 2019-01-23

#### Added
- `@hundh/contao-utils-bundle`
Expand Down
65 changes: 36 additions & 29 deletions src/ConfigElementType/YouTubeListConfigElementType.php
Expand Up @@ -16,39 +16,46 @@
use HeimrichHannot\ListBundle\Model\ListConfigElementModel;
use HeimrichHannot\YoutubeBundle\Configuration\ConfigFactory;

class YouTubeListConfigElementType implements ConfigElementType
{
const TYPE = 'youtube';

/**
* @var ContaoFrameworkInterface
*/
private $framework;

public function __construct(ContaoFrameworkInterface $framework)
if (class_exists('HeimrichHannot\ListBundle\HeimrichHannotContaoListBundle')) {
class YouTubeListConfigElementType implements ConfigElementType
{
$this->framework = $framework;
}
const TYPE = 'youtube';

public function addToItemData(ItemInterface $item, ListConfigElementModel $listConfigElement)
{
if (!$item->getRawValue($listConfigElement->youtubeSelectorField)) {
return;
/**
* @var ContaoFrameworkInterface
*/
private $framework;

public function __construct(ContaoFrameworkInterface $framework)
{
$this->framework = $framework;
}

if ((!$youtubeData = $item->getRawValue($listConfigElement->youtubeField)) || empty($youtubeData)) {
return;
public function addToItemData(ItemInterface $item, ListConfigElementModel $listConfigElement)
{
if (!$item->getRawValue($listConfigElement->youtubeSelectorField)) {
return;
}

if ((!$youtubeData = $item->getRawValue($listConfigElement->youtubeField)) || empty($youtubeData)) {
return;
}
$configData = [
'type' => 'youtube',
'addYouTube' => true,
'youtube' => $youtubeData,
];

$video = System::getContainer()->get('huh.youtube.videocreator')->createVideo(ConfigFactory::CONTEXT_LIST_BUNDLE, array_merge($item->getRaw(), $configData));
$template = new FrontendTemplate();
$video->addToTemplate($template);
$templateData = $template->getData();
$item->setFormattedValue('youtubeVideos', [$listConfigElement->youtubeField => (array) $templateData['youtube']]);
}
$configData = [
'type' => 'youtube',
'addYouTube' => true,
'youtube' => $youtubeData,
];

$video = System::getContainer()->get('huh.youtube.videocreator')->createVideo(ConfigFactory::CONTEXT_LIST_BUNDLE, array_merge($item->getRaw(), $configData));
$template = new FrontendTemplate();
$video->addToTemplate($template);
$templateData = $template->getData();
$item->setFormattedValue('youtubeVideos', [$listConfigElement->youtubeField => (array) $templateData['youtube']]);
}
} else {
class YouTubeListConfigElementType
{
const TYPE = 'youtube';
}
}
67 changes: 37 additions & 30 deletions src/ConfigElementType/YoutubeReaderConfigElementType.php
Expand Up @@ -16,40 +16,47 @@
use HeimrichHannot\ReaderBundle\Model\ReaderConfigElementModel;
use HeimrichHannot\YoutubeBundle\Configuration\ConfigFactory;

class YoutubeReaderConfigElementType implements ConfigElementType
{
const TYPE = 'youtube';

/**
* @var ContaoFrameworkInterface
*/
private $framework;

public function __construct(ContaoFrameworkInterface $framework)
if (class_exists('HeimrichHannot\ReaderBundle\HeimrichHannotContaoReaderBundle')) {
class YoutubeReaderConfigElementType implements ConfigElementType
{
$this->framework = $framework;
}
const TYPE = 'youtube';

public function addToItemData(ItemInterface $item, ReaderConfigElementModel $readerConfigElement)
{
if (!$item->getRawValue($readerConfigElement->youtubeSelectorField)) {
return;
/**
* @var ContaoFrameworkInterface
*/
private $framework;

public function __construct(ContaoFrameworkInterface $framework)
{
$this->framework = $framework;
}

if ((!$youtubeData = $item->getRawValue($readerConfigElement->youtubeField)) || empty($youtubeData)) {
return;
public function addToItemData(ItemInterface $item, ReaderConfigElementModel $readerConfigElement)
{
if (!$item->getRawValue($readerConfigElement->youtubeSelectorField)) {
return;
}

if ((!$youtubeData = $item->getRawValue($readerConfigElement->youtubeField)) || empty($youtubeData)) {
return;
}
$configData = [
'type' => 'youtube',
'addYouTube' => true,
'youtube' => $youtubeData,
'autoplay' => $readerConfigElement->autoplay,
];

$video = System::getContainer()->get('huh.youtube.videocreator')->createVideo(ConfigFactory::CONTEXT_READER_BUNDLE, array_merge($item->getRaw(), $configData));
$template = new FrontendTemplate();
$video->addToTemplate($template);
$templateData = $template->getData();
$item->setFormattedValue('youtubeVideos', [$readerConfigElement->youtubeField => (array) $templateData['youtube']]);
}
$configData = [
'type' => 'youtube',
'addYouTube' => true,
'youtube' => $youtubeData,
'autoplay' => $readerConfigElement->autoplay,
];

$video = System::getContainer()->get('huh.youtube.videocreator')->createVideo(ConfigFactory::CONTEXT_LIST_BUNDLE, array_merge($item->getRaw(), $configData));
$template = new FrontendTemplate();
$video->addToTemplate($template);
$templateData = $template->getData();
$item->setFormattedValue('youtubeVideos', [$readerConfigElement->youtubeField => (array) $templateData['youtube']]);
}
} else {
class YoutubeReaderConfigElementType
{
const TYPE = 'youtube';
}
}

0 comments on commit 9d8d79e

Please sign in to comment.