You are here

class BackgroundVideoManager in Background Video 8

Class BackgroundVideoManager

@package Drupal\background_video\Manager.

Hierarchy

Expanded class hierarchy of BackgroundVideoManager

1 string reference to 'BackgroundVideoManager'
background_video.services.yml in ./background_video.services.yml
background_video.services.yml
1 service uses BackgroundVideoManager
background_video.manager in ./background_video.services.yml
Drupal\background_video\Manager\BackgroundVideoManager

File

src/Manager/BackgroundVideoManager.php, line 13

Namespace

Drupal\background_video\Manager
View 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