1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
$root = dirname(__DIR__); |
4
|
|
|
|
5
|
|
|
include "$root/vendor/autoload.php"; |
6
|
|
|
|
7
|
|
|
use Doctrine\Common\Cache\FilesystemCache as Cache; |
8
|
|
|
use Libcast\AssetDistributor\Owner; |
9
|
|
|
use Libcast\AssetDistributor\Asset\AssetFactory; |
10
|
|
|
use Libcast\AssetDistributor\Adapter\AdapterCollection; |
11
|
|
|
use Libcast\AssetDistributor\Dailymotion\DailymotionAdapter; |
12
|
|
|
use Libcast\AssetDistributor\Vimeo\VimeoAdapter; |
13
|
|
|
use Libcast\AssetDistributor\YouTube\YouTubeAdapter; |
14
|
|
|
use Monolog\Logger; |
15
|
|
|
use Monolog\Handler\StreamHandler; |
16
|
|
|
|
17
|
|
|
$configPath = 'configuration.ini'; |
18
|
|
|
|
19
|
|
|
// Optional: set a logger |
20
|
|
|
$logger = new Logger('distributor'); |
21
|
|
|
$logger->pushHandler(new StreamHandler("$root/example/debug.log", Logger::DEBUG)); |
22
|
|
|
|
23
|
|
|
// Create an Owner |
24
|
|
|
$owner = new Owner('johndoe', new Cache("$root/example/cache")); |
25
|
|
|
|
26
|
|
|
// Create an Asset |
27
|
|
|
$asset = AssetFactory::build( |
28
|
|
|
"$root/tests/video.mp4", // path to file, or a Flysystem\File object |
29
|
|
|
'My Video', // optional title |
30
|
|
|
'This is an awesome video', // optional description |
31
|
|
|
['test', 'asset-distributor'] // optional array of tags |
32
|
|
|
); |
33
|
|
|
$asset->setVisibility('private'); // Make video private (public by default) |
|
|
|
|
34
|
|
|
|
35
|
|
|
// Create a collection of Adapters that will manage the Asset with Owner credentials |
36
|
|
|
$adapters = new AdapterCollection; |
37
|
|
|
$adapters[] = new YouTubeAdapter($owner, $configPath, $logger); |
38
|
|
|
$adapters[] = new VimeoAdapter($owner, $configPath, $logger); |
39
|
|
|
$adapters[] = new DailymotionAdapter($owner, $configPath, $logger); |
40
|
|
|
|
41
|
|
|
// Affect the Adapter collection to the Owner |
42
|
|
|
$owner->setAdapters($adapters); |
43
|
|
|
|
44
|
|
|
// Now the Owner may manipulate the Asset |
45
|
|
|
$owner->upload($asset); |
46
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.