/** * Sets the default properties. */ public function __construct(array $properties = []) { $this->_properties = $properties + ['providers' => ESSENCE_DEFAULT_PROVIDERS, 'Cache' => Container::unique(function () { return new VolatileCacheEngine(); }), 'HttpUserAgent' => 'Essence', 'Http' => Container::unique(function ($C) { $Http = function_exists('curl_init') ? new CurlHttpClient() : new NativeHttpClient(); $Http->setUserAgent($C->get('HttpUserAgent')); return $Http; }), 'Dom' => Container::unique(function () { return new NativeDomParser(); }), 'Log' => Container::unique(function () { return new NullLogger(); }), 'Preparator' => Container::unique(function () { return new Preparator(); }), 'OEmbed' => function ($C) { return new OEmbed($C->get('Http'), $C->get('Dom'), $C->get('Log'), $C->get('Preparator')); }, 'Vimeo' => function ($C) { return new Vimeo($C->get('Http'), $C->get('Dom'), $C->get('Log'), $C->get('Preparator')); }, 'YoutubePreparator' => Container::unique(function () { return new YoutubePreparator(); }), 'Youtube' => function ($C) { return new Youtube($C->get('Http'), $C->get('Dom'), $C->get('Log'), $C->get('YoutubePreparator')); }, 'OpenGraph' => function ($C) { return new OpenGraph($C->get('Http'), $C->get('Dom'), $C->get('Log'), $C->get('Preparator')); }, 'BandcampPreparator' => Container::unique(function () { return new BandcampPreparator(); }), 'Bandcamp' => function ($C) { return new OpenGraph($C->get('Http'), $C->get('Dom'), $C->get('Log'), $C->get('BandcampPreparator')); }, 'VinePreparator' => Container::unique(function () { return new VinePreparator(); }), 'Vine' => function ($C) { return new OpenGraph($C->get('Http'), $C->get('Dom'), $C->get('Log'), $C->get('VinePreparator')); }, 'Collection' => function ($C) { $Collection = new Collection($C); $Collection->load($C->get('providers')); return $Collection; }, 'Essence' => function ($C) { return new Essence($C->get('Collection'), $C->get('Cache'), $C->get('Http'), $C->get('Dom'), $C->get('Log')); }]; }
/** * Configures the providers collection. */ protected function _setupCollection() { $this->configure(['Collection.providers' => dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'providers.json', 'Collection' => Container::unique(function ($C) { $Collection = new Collection($C); $Collection->load($C->get('Collection.providers')); return $Collection; })]); }