Skip to content

Commit

Permalink
Video Parameter (#98)
Browse files Browse the repository at this point in the history
* allow video parameters, see #97

* fixes after code review

* skip empty initial video type config
  • Loading branch information
solverat committed Feb 20, 2019
1 parent 07a6fb6 commit 504df1c
Show file tree
Hide file tree
Showing 15 changed files with 556 additions and 333 deletions.
1 change: 1 addition & 0 deletions UPGRADE.md
Expand Up @@ -8,6 +8,7 @@ Just click the "update" button or execute the migration command to finish the bu

#### Update from Version 2.6.x to Version 2.7.0
- **[ATTENTION]**: Installer has moved to the [MigrationBundle](https://github.com/dachcom-digital/pimcore-toolbox/issues/89). After updating to this version you need to enable this extension again!
- **[NEW FEATURE]**: Parameter for video elements (e.g. youtube api parameters)
- ([Milestone for 2.7.0](https://github.com/dachcom-digital/pimcore-toolbox/milestone/12?closed=1))

#### Update from Version 2.6.4 to Version 2.6.5
Expand Down
5 changes: 4 additions & 1 deletion src/ToolboxBundle/Document/Areabrick/Video/Video.php
Expand Up @@ -22,7 +22,9 @@ public function action(Info $info)
/** @var \ToolboxBundle\Model\Document\Tag\Vhs $videoTag */
$videoTag = $this->getDocumentTag($info->getDocument(), 'vhs', 'video');

$playInLightBox = $videoTag->getShowAsLightbox() === true ? 'true' : 'false';
$videoParameter = $videoTag->getVideoParameter();

$playInLightBox = $videoTag->getShowAsLightBox() === true ? 'true' : 'false';
/** @var \Pimcore\Model\Document\Tag\Checkbox $autoPlayElement */
$autoPlayElement = $this->getDocumentTag($info->getDocument(), 'checkbox', 'autoplay');
$autoPlay = $autoPlayElement->isChecked() === true && !$view->get('editmode');
Expand All @@ -42,6 +44,7 @@ public function action(Info $info)
'posterPath' => $posterPath,
'videoType' => $videoType,
'playInLightbox' => $playInLightBox,
'videoParameter' => $videoParameter,
'videoId' => $videoId
]);
}
Expand Down
54 changes: 37 additions & 17 deletions src/ToolboxBundle/Model/Document/Tag/Vhs.php
Expand Up @@ -10,14 +10,19 @@ class Vhs extends Model\Document\Tag\Video
/**
* @var bool
*/
public $showAsLightbox = false;
public $showAsLightBox = false;

/**
* Enum: [asset, youtube, vimeo, dailymotion].
*
* @var string
*/
public $type = '';
public $type;

/**
* @var array
*/
public $videoParameter;

/**
* Return the type of the element.
Expand All @@ -30,42 +35,52 @@ public function getType()
}

/**
* @param bool $showAsLightbox
*
* @return $this
* @return string
*/
public function setShowAsLightbox($showAsLightbox)
public function getShowAsLightBox()
{
$this->showAsLightbox = $showAsLightbox;

return $this;
return $this->showAsLightBox;
}

/**
* @return string
* @return array
*/
public function getShowAsLightbox()
public function getVideoParameter()
{
return $this->showAsLightbox;
if (!is_array($this->videoParameter)) {
return [];
}

$parsedParameter = [];
foreach ($this->videoParameter as $parameter) {
$parsedParameter[$parameter['key']] = $parameter['value'];
}

return $parsedParameter;
}

/**
* @see Document\Tag\TagInterface::getData
*
* @return mixed
* @return array
*/
public function getData()
{
$data = parent::getData();
$data['showAsLightbox'] = $this->showAsLightbox;
$data['showAsLightbox'] = $this->showAsLightBox;
$data['videoParameter'] = $this->videoParameter;

return $data;
}

/**
* @return array
*/
public function getDataForResource()
{
$data = parent::getDataForResource();
$data['showAsLightbox'] = $this->showAsLightbox;
$data['showAsLightbox'] = $this->showAsLightBox;
$data['videoParameter'] = $this->videoParameter;

return $data;
}
Expand All @@ -85,7 +100,8 @@ public function setDataFromResource($data)
$data = \Pimcore\Tool\Serialize::unserialize($data);
}

$this->showAsLightbox = $data['showAsLightbox'];
$this->showAsLightBox = $data['showAsLightbox'];
$this->videoParameter = $data['videoParameter'];

return $this;
}
Expand All @@ -102,7 +118,11 @@ public function setDataFromEditmode($data)
parent::setDataFromEditmode($data);

if ($data['showAsLightbox']) {
$this->showAsLightbox = $data['showAsLightbox'];
$this->showAsLightBox = $data['showAsLightbox'];
}

if ($data['videoParameter']) {
$this->videoParameter = $data['videoParameter'];
}

return $this;
Expand Down

0 comments on commit 504df1c

Please sign in to comment.