nystudio107 /
craft-transcoder
| 1 | <?php |
||||
| 2 | /** |
||||
| 3 | * Transcoder plugin for Craft CMS |
||||
| 4 | * |
||||
| 5 | * Transcode videos to various formats, and provide thumbnails of the video |
||||
| 6 | * |
||||
| 7 | * @link https://nystudio107.com |
||||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||||
| 8 | * @copyright Copyright (c) 2022 nystudio107 |
||||
|
0 ignored issues
–
show
|
|||||
| 9 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 10 | |||||
| 11 | namespace nystudio107\transcoder\services; |
||||
| 12 | |||||
| 13 | use nystudio107\pluginvite\services\VitePluginService; |
||||
| 14 | use nystudio107\transcoder\assetbundles\transcoder\TranscoderAsset; |
||||
| 15 | use yii\base\InvalidConfigException; |
||||
| 16 | |||||
| 17 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 18 | * @author nystudio107 |
||||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||||
| 19 | * @package Transcode |
||||
|
0 ignored issues
–
show
|
|||||
| 20 | * @since 1.2.23 |
||||
|
0 ignored issues
–
show
|
|||||
| 21 | * |
||||
| 22 | * @property Transcode $transcode |
||||
| 23 | * @property VitePluginService $vite |
||||
| 24 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 25 | trait ServicesTrait |
||||
| 26 | { |
||||
| 27 | // Public Static Methods |
||||
| 28 | // ========================================================================= |
||||
| 29 | |||||
| 30 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 31 | * @inheritdoc |
||||
| 32 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 33 | public static function config(): array |
||||
| 34 | { |
||||
| 35 | // Constants aren't allowed in traits until PHP >= 8.2, and config() is called before __construct(), |
||||
| 36 | // so we can't extract it from the passed in $config |
||||
| 37 | $majorVersion = '5'; |
||||
| 38 | // Dev server container name & port are based on the major version of this plugin |
||||
| 39 | $devPort = 3000 + (int)$majorVersion; |
||||
| 40 | $versionName = 'v' . $majorVersion; |
||||
| 41 | return [ |
||||
| 42 | 'components' => [ |
||||
| 43 | 'transcode' => Transcode::class, |
||||
| 44 | // Register the vite service |
||||
| 45 | 'vite' => [ |
||||
| 46 | 'class' => VitePluginService::class, |
||||
| 47 | 'assetClass' => TranscoderAsset::class, |
||||
| 48 | 'useDevServer' => true, |
||||
| 49 | 'devServerInternal' => 'http://craft-transcoder-' . $versionName . '-buildchain-dev:' . $devPort, |
||||
| 50 | 'devServerPublic' => 'http://localhost:' . $devPort, |
||||
| 51 | 'errorEntry' => 'src/js/app.ts', |
||||
| 52 | 'checkDevServer' => true, |
||||
| 53 | ], |
||||
| 54 | ], |
||||
| 55 | ]; |
||||
| 56 | } |
||||
| 57 | |||||
| 58 | // Public Methods |
||||
| 59 | // ========================================================================= |
||||
| 60 | |||||
| 61 | /** |
||||
| 62 | * Returns the transcode service |
||||
| 63 | * |
||||
| 64 | * @return Transcode The transcode service |
||||
| 65 | * @throws InvalidConfigException |
||||
| 66 | */ |
||||
| 67 | public function getTranscode(): Transcode |
||||
| 68 | { |
||||
| 69 | return $this->get('transcode'); |
||||
|
0 ignored issues
–
show
It seems like
get() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 70 | } |
||||
| 71 | |||||
| 72 | /** |
||||
| 73 | * Returns the vite service |
||||
| 74 | * |
||||
| 75 | * @return VitePluginService The vite service |
||||
| 76 | * @throws InvalidConfigException |
||||
| 77 | */ |
||||
| 78 | public function getVite(): VitePluginService |
||||
| 79 | { |
||||
| 80 | return $this->get('vite'); |
||||
| 81 | } |
||||
| 82 | } |
||||
| 83 |