Skip to content

Commit 46180cb

Browse files
authored
added setComponents to get access to services
I didn't find a way to get access to functions from the services (like getVideoUrl) on API/PHP level, so I added the setComponents function to define a method to call them; ``` use nystudio107\transcoder\Transcoder; // where $video is the reference to the asset $encodedVideoUrl = Transcoder::$plugin->get->getVideoUrl($video, []); $encodedThumbnail = Transcoder::$plugin->get->getVideoThumbnailUrl($video, [ 'width' => 800, 'height' => 450, 'timeInSecs' => 5 ]); ``` This seem to work now.
1 parent 3c3f703 commit 46180cb

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Transcoder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public function init()
5757
parent::init();
5858
self::$plugin = $this;
5959

60+
// Load plugin components
61+
$this->setComponents([
62+
'get' => Transcode::class
63+
]);
64+
6065
// Register our variables
6166
Event::on(
6267
CraftVariable::class,

0 commit comments

Comments
 (0)