class BackgroundVideoManager in Background Video 8
Class BackgroundVideoManager
@package Drupal\background_video\Manager.
Hierarchy
- class \Drupal\background_video\Manager\BackgroundVideoManager
Expanded class hierarchy of BackgroundVideoManager
1 string reference to 'BackgroundVideoManager'
1 service uses BackgroundVideoManager
File
- src/
Manager/ BackgroundVideoManager.php, line 13
Namespace
Drupal\background_video\ManagerView source
class BackgroundVideoManager {
protected $config;
public function __construct(ConfigFactoryInterface $config) {
$this->config = $config
->get('config.background_video');
}
/**
* Returns JS settings.
* @return array
*/
public function getJsSettings() {
return [
'mp4' => self::_background_video_geturl_preprocess_page('mp4'),
'ogv' => self::_background_video_geturl_preprocess_page('ogv'),
'webm' => self::_background_video_geturl_preprocess_page('webm'),
'control_pos' => $this->config
->get('background_video_control_position'),
'loop' => $this->config
->get('background_video_loop'),
'auto_play' => $this->config
->get('background_video_autoplay'),
'video_id' => $this->config
->get('background_video_id'),
];
}
public function _background_video_geturl_preprocess_page($type) {
$fid = $this->config
->get('background_video_source_' . $type)[0];
if (!empty($fid)) {
$file = File::load($fid);
if ($file) {
return file_create_url($file
->toArray()['uri'][0]['value']);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BackgroundVideoManager:: |
protected | property | ||
BackgroundVideoManager:: |
public | function | Returns JS settings. | |
BackgroundVideoManager:: |
public | function | ||
BackgroundVideoManager:: |
public | function |