Skip to content

Commit

Permalink
refactor: ECS code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Sep 30, 2024
1 parent 7e660c2 commit f282711
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/Transcoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected function addComponents(): void
Event::on(
CraftVariable::class,
CraftVariable::EVENT_INIT,
function (Event $event) {
function(Event $event) {
/** @var CraftVariable $variable */
$variable = $event->sender;
$variable->set('transcoder', [
Expand All @@ -176,7 +176,7 @@ protected function installEventHandlers(): void
Event::on(
Assets::class,
Assets::EVENT_DEFINE_THUMB_URL,
static function (DefineAssetThumbUrlEvent $event) {
static function(DefineAssetThumbUrlEvent $event) {
Craft::debug(
'Assets::EVENT_GET_THUMB_PATH',
__METHOD__
Expand All @@ -195,7 +195,7 @@ static function (DefineAssetThumbUrlEvent $event) {
Event::on(
ClearCaches::class,
ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
function (RegisterCacheOptionsEvent $event) {
function(RegisterCacheOptionsEvent $event) {
$event->options[] = [
'key' => 'transcoder',
'label' => Craft::t('transcoder', 'Transcoder caches'),
Expand All @@ -208,7 +208,7 @@ function (RegisterCacheOptionsEvent $event) {
Event::on(
Plugins::class,
Plugins::EVENT_AFTER_INSTALL_PLUGIN,
function (PluginEvent $event) {
function(PluginEvent $event) {
if ($event->plugin === $this) {
$request = Craft::$app->getRequest();
if ($request->isCpRequest) {
Expand All @@ -233,7 +233,7 @@ protected function installSiteEventListeners(): void
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_SITE_URL_RULES,
function (RegisterUrlRulesEvent $event) {
function(RegisterUrlRulesEvent $event) {
Craft::debug(
'UrlManager::EVENT_REGISTER_SITE_URL_RULES',
__METHOD__
Expand Down
2 changes: 1 addition & 1 deletion src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
'timeInSecs' => '',
'seekInSecs' => '',
'synchronous' => false,
'stripMetadata' => false
'stripMetadata' => false,
],

// Default options for Gif encoding
Expand Down
2 changes: 1 addition & 1 deletion src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class Settings extends Model
'audioSampleRate' => '44100',
'audioChannels' => '2',
'synchronous' => false,
'stripMetadata' => false
'stripMetadata' => false,
];

/**
Expand Down
2 changes: 1 addition & 1 deletion src/services/ServicesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function config(): array
'devServerInternal' => 'http://craft-transcoder-buildchain:3001',
'checkDevServer' => true,
],
]
],
];
}

Expand Down
5 changes: 2 additions & 3 deletions src/services/Transcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function getVideoUrl(string|Asset $filePath, array $videoOptions, bool $g
if (file_exists($destVideoPath) && (@filemtime($destVideoPath) >= @filemtime($filePath))) {
$url = $settings['transcoderUrls']['video'] . $subfolder ?? $settings['transcoderUrls']['default'];

Check failure on line 210 in src/services/Transcode.php

View workflow job for this annotation

GitHub Actions / PHPStan

Expression on left side of ?? is not nullable.
$result = App::parseEnv($url) . $destVideoFile;
// skip encoding
// skip encoding
} elseif (!$generate) {
$result = '';
} else {
Expand Down Expand Up @@ -296,9 +296,8 @@ public function getVideoThumbnailUrl(Asset|string $filePath, array $thumbnailOpt
$shellOutput = $this->executeShellCommand($ffmpegCmd);
Craft::info($ffmpegCmd, __METHOD__);

// if ffmpeg fails which we can't check because the process is ran in the background
// if ffmpeg fails which we can't check because the process is ran in the background
// don't return the future path of the image or else we can't check this in the front end

} else {
Craft::info('Thumbnail does not exist, but not asked to generate it: ' . $filePath, __METHOD__);

Expand Down
2 changes: 1 addition & 1 deletion src/translations/en/transcoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
'{name} plugin loaded' => '{name} plugin loaded',
'{name} cache directory cleared' => '{name} cache directory cleared',
'Manifest file not found at: {manifestPath}' => 'Manifest file not found at: {manifestPath}',
'Module does not exist in the manifest: {moduleName}' => 'Module does not exist in the manifest: {moduleName}'
'Module does not exist in the manifest: {moduleName}' => 'Module does not exist in the manifest: {moduleName}',
];

0 comments on commit f282711

Please sign in to comment.