BrightcoveProxyInitSubscriber.php in Brightcove Video Connect 8
File
modules/brightcove_proxy/src/EventSubscriber/BrightcoveProxyInitSubscriber.php
View source
<?php
namespace Drupal\brightcove_proxy\EventSubscriber;
use Brightcove\API\Client;
use Drupal\Core\Config\ConfigFactory;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class BrightcoveProxyInitSubscriber implements EventSubscriberInterface {
protected $config;
public function __construct(ConfigFactory $config) {
$this->config = $config
->get('brightcove_proxy.config');
}
public function initializeBrightcoveClientProxy(GetResponseEvent $event) {
if ($this->config
->get('use_proxy')) {
Client::$proxyUserPassword = "{$this->config->get('proxy_username')}:{$this->config->get('proxy_password')}";
Client::$httpProxyTunnel = $this->config
->get('http_proxy_tunnel');
Client::$proxyAuth = $this->config
->get('proxy_auth');
Client::$proxyPort = $this->config
->get('proxy_port');
Client::$proxyType = $this->config
->get('proxy_type');
Client::$proxy = $this->config
->get('proxy');
}
}
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = [
'initializeBrightcoveClientProxy',
];
return $events;
}
}