Skip to content

Commit

Permalink
Added view defaults & fix text
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Notbohm committed Dec 20, 2017
1 parent a958791 commit d0d2bcd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions doc/book/helpers/video.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ You can use this view helper to easily display videos in a HTML5 tag. The syntax
for the view helper is `$this->video($source, $attribs)`, using the
following definitions for the helper arguments:

- `$source`: A string with the src to video file or an an array with many sources
- `$source`: A string value with the path to a video file or an array
with different sources
- `$attribs`: An array of html attributes

## Basic Usage
Expand All @@ -14,7 +15,7 @@ The following example shows a simple configuration for only one video file forma
```php
$this->video('/video/file.mp4',
['controls' =>
'controls' => true,
'loop' => true,
'width' => '400',
'height' => '800'
]);
Expand All @@ -28,7 +29,7 @@ $this->video([
['src' => '/video/file.ogg', 'type' => 'video/ogg']
],
['controls' =>
'controls' => true,
'loop' => true,
'width' => '400',
'height' => '800'
]);
Expand Down
7 changes: 7 additions & 0 deletions src/Helper/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,20 @@ class Video extends AbstractHtmlElement
*/
protected $sources;

/**
* @var
*/
protected $defaults = ['controls' => true];

/**
* @param string|array $source
* @param array $attribs
* @return string
*/
public function __invoke($source, $attribs = [])
{
$attribs = array_merge($this->defaults, $attribs);

if (is_string($source)) {
$attribs = array_merge(['src' => $source], $attribs);
}
Expand Down

0 comments on commit d0d2bcd

Please sign in to comment.