Skip to content

Commit fa4badb

Browse files
committed
### Changed
* `hasSettings` -> `hasCpSettings` for Craft 3 beta 8 compatibility * Added Craft 3 beta 8 compatible settings * Modified config service calls for Craft 3 beta 8
1 parent 15b46a9 commit fa4badb

File tree

10 files changed

+428
-187
lines changed

10 files changed

+428
-187
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
## 1.0.5 - 2017.03.24
44
### Changed
55
* `hasSettings` -> `hasCpSettings` for Craft 3 beta 8 compatibility
6+
* Added Craft 3 beta 8 compatible settings
7+
* Modified config service calls for Craft 3 beta 8
68

79
## 1.0.4 - 2017.03.12
810
### Added

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"hasCpSection": false,
3939
"changelogUrl": "https://raw.githubusercontent.com/nystudio107/craft3-transcoder/master/CHANGELOG.md",
4040
"components": {
41-
"transcoder": "nystudio107\\transcoder\\services\\Transcoder"
41+
"transcode": "nystudio107\\transcoder\\services\\Transcode"
4242
},
4343
"class": "nystudio107\\transcoder\\Transcoder"
4444
}

src/Transcoder.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010

1111
namespace nystudio107\transcoder;
1212

13-
use nystudio107\transcoder\services\Transcoder as TranscoderService;
13+
use nystudio107\transcoder\services\Transcode;
1414
use nystudio107\transcoder\variables\TranscoderVariable;
15+
use nystudio107\transcoder\models\Settings;
1516

1617
use Craft;
1718
use craft\base\Plugin;
@@ -22,13 +23,13 @@
2223
use yii\base\Event;
2324

2425
/**
25-
* Class Transcoder
26+
* Class Transcode
2627
*
2728
* @author nystudio107
28-
* @package Transcoder
29+
* @package Transcode
2930
* @since 1.0.0
3031
*
31-
* @property TranscoderService transcoder
32+
* @property Transcode $transcode
3233
*/
3334
class Transcoder extends Plugin
3435
{
@@ -56,20 +57,27 @@ public function init()
5657
$this->controllerNamespace = 'nystudio107\transcoder\console\controllers';
5758
}
5859

59-
// Add the Transcoder path to the list of things the Clear Caches tool can delete.
60+
// Add the Transcode path to the list of things the Clear Caches tool can delete.
6061
Event::on(
6162
ClearCaches::className(),
6263
ClearCaches::EVENT_REGISTER_CACHE_OPTIONS,
6364
function (RegisterCacheOptionsEvent $event) {
6465
$event->options[] = [
6566
'key' => 'transcoder',
6667
'label' => Craft::t('transcoder', 'Transcoder caches'),
67-
'action' => Craft::$app->config->get('transcoderPath', 'transcoder')
68+
'action' => Transcoder::$plugin->getSettings()->transcoderPath,
6869
];
6970
}
7071
);
7172

72-
Craft::info('Transcoder ' . Craft::t('transcoder', 'plugin loaded'), __METHOD__);
73+
Craft::info(
74+
Craft::t(
75+
'transcoder',
76+
'{name} plugin loaded',
77+
['name' => $this->name]
78+
),
79+
__METHOD__
80+
);
7381
}
7482

7583
/**
@@ -79,4 +87,15 @@ public function defineTemplateComponent()
7987
{
8088
return TranscoderVariable::class;
8189
}
90+
91+
// Protected Methods
92+
// =========================================================================
93+
94+
/**
95+
* @inheritdoc
96+
*/
97+
protected function createSettingsModel()
98+
{
99+
return new Settings();
100+
}
82101
}

src/config.php

Lines changed: 67 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111
/**
1212
* Transcoder config.php
1313
*
14-
* Completely optional configuration settings for Transcoder if you want to
15-
* customize some of its more esoteric behavior, or just want specific control
16-
* over things.
14+
* This file exists only as a template for the Transcoder settings.
15+
* It does nothing on its own.
1716
*
1817
* Don't edit this file, instead copy it to 'craft/config' as 'transcoder.php'
19-
* and make your changes there.
18+
* and make your changes there to override default settings.
2019
*
2120
* Once copied to 'craft/config', this file will be multi-environment aware as
2221
* well, so you can have different settings groups for each environment, just as
@@ -26,103 +25,103 @@
2625
return [
2726

2827
// The path to the ffmpeg binary
29-
"ffmpegPath" => "/usr/bin/ffmpeg",
28+
'ffmpegPath' => '/usr/bin/ffmpeg',
3029

3130
// The path to the ffprobe binary
32-
"ffprobePath" => "/usr/bin/ffprobe",
31+
'ffprobePath' => '/usr/bin/ffprobe',
3332

3433
// The options to use for ffprobe
35-
"ffprobeOptions" => "-v quiet -print_format json -show_format -show_streams",
34+
'ffprobeOptions' => '-v quiet -print_format json -show_format -show_streams',
3635

3736
// The path where the transcoded videos are stored; must have a trailing /
38-
"transcoderPath" => $_SERVER['DOCUMENT_ROOT'] . "/transcoder/",
37+
'transcoderPath' => '{DOCUMENT_ROOT}/transcoder/',
3938

4039
// The URL where the transcoded videos are stored; must have a trailing /
41-
"transcoderUrl" => "/transcoder/",
40+
'transcoderUrl' => '/transcoder/',
4241

4342
// Use a md5 hash for the filenames instead of parameterized naming
44-
"useHashedNames" => false,
43+
'useHashedNames' => false,
4544

4645
// Preset video encoders
47-
"videoEncoders" => [
48-
"h264" => [
49-
"fileSuffix" => ".mp4",
50-
"fileFormat" => "mp4",
51-
"videoCodec" => "libx264",
52-
"videoCodecOptions" => "-vprofile high -preset slow -crf 22",
53-
"audioCodec" => "libfdk_aac",
54-
"audioCodecOptions" => "-async 1000",
46+
'videoEncoders' => [
47+
'h264' => [
48+
'fileSuffix' => '.mp4',
49+
'fileFormat' => 'mp4',
50+
'videoCodec' => 'libx264',
51+
'videoCodecOptions' => '-vprofile high -preset slow -crf 22',
52+
'audioCodec' => 'libfdk_aac',
53+
'audioCodecOptions' => '-async 1000',
5554
],
56-
"webm" => [
57-
"fileSuffix" => ".webm",
58-
"fileFormat" => "webm",
59-
"videoCodec" => "libvpx",
60-
"videoCodecOptions" => "-quality good -cpu-used 0",
61-
"audioCodec" => "libvorbis",
62-
"audioCodecOptions" => "-async 1000",
55+
'webm' => [
56+
'fileSuffix' => '.webm',
57+
'fileFormat' => 'webm',
58+
'videoCodec' => 'libvpx',
59+
'videoCodecOptions' => '-quality good -cpu-used 0',
60+
'audioCodec' => 'libvorbis',
61+
'audioCodecOptions' => '-async 1000',
6362
],
6463
],
6564

6665
// Preset audio encoders
67-
"audioEncoders" => [
68-
"mp3" => [
69-
"fileSuffix" => ".mp3",
70-
"fileFormat" => "mp3",
71-
"audioCodec" => "libmp3lame",
72-
"audioCodecOptions" => "",
66+
'audioEncoders' => [
67+
'mp3' => [
68+
'fileSuffix' => '.mp3',
69+
'fileFormat' => 'mp3',
70+
'audioCodec' => 'libmp3lame',
71+
'audioCodecOptions' => '',
7372
],
74-
"aac" => [
75-
"fileSuffix" => ".m4a",
76-
"fileFormat" => "aac",
77-
"audioCodec" => "libfdk_aac",
78-
"audioCodecOptions" => "",
73+
'aac' => [
74+
'fileSuffix' => '.m4a',
75+
'fileFormat' => 'aac',
76+
'audioCodec' => 'libfdk_aac',
77+
'audioCodecOptions' => '',
7978

8079
],
81-
"ogg" => [
82-
"fileSuffix" => ".ogg",
83-
"fileFormat" => "ogg",
84-
"audioCodec" => "libvorbis",
85-
"audioCodecOptions" => "",
80+
'ogg' => [
81+
'fileSuffix' => '.ogg',
82+
'fileFormat' => 'ogg',
83+
'audioCodec' => 'libvorbis',
84+
'audioCodecOptions' => '',
8685
],
8786
],
8887

8988
// Default options for encoded videos
90-
"defaultVideoOptions" => [
89+
'defaultVideoOptions' => [
9190
// Video settings
92-
"videoEncoder" => "h264",
93-
"videoBitRate" => "800k",
94-
"videoFrameRate" => 15,
91+
'videoEncoder' => 'h264',
92+
'videoBitRate' => '800k',
93+
'videoFrameRate' => 15,
9594
// Audio settings
96-
"audioBitRate" => "",
97-
"audioSampleRate" => "",
98-
"audioChannels" => "",
95+
'audioBitRate' => '',
96+
'audioSampleRate' => '',
97+
'audioChannels' => '',
9998
// Spatial settings
100-
"width" => "",
101-
"height" => "",
102-
"sharpen" => true,
103-
// Can be "none", "crop", or "letterbox"
104-
"aspectRatio" => "letterbox",
105-
"letterboxColor" => "",
99+
'width' => '',
100+
'height' => '',
101+
'sharpen' => true,
102+
// Can be 'none', 'crop', or 'letterbox'
103+
'aspectRatio' => 'letterbox',
104+
'letterboxColor' => '',
106105
],
107106

108107
// Default options for video thumbnails
109-
"defaultThumbnailOptions" => [
110-
"fileSuffix" => ".jpg",
111-
"timeInSecs" => 10,
112-
"width" => "",
113-
"height" => "",
114-
"sharpen" => true,
115-
// Can be "none", "crop", or "letterbox"
116-
"aspectRatio" => "letterbox",
117-
"letterboxColor" => "",
108+
'defaultThumbnailOptions' => [
109+
'fileSuffix' => '.jpg',
110+
'timeInSecs' => 10,
111+
'width' => '',
112+
'height' => '',
113+
'sharpen' => true,
114+
// Can be 'none', 'crop', or 'letterbox'
115+
'aspectRatio' => 'letterbox',
116+
'letterboxColor' => '',
118117
],
119118

120119
// Default options for encoded videos
121-
"defaultAudioOptions" => [
122-
"audioEncoder" => "mp3",
123-
"audioBitRate" => "128k",
124-
"audioSampleRate" => "44100",
125-
"audioChannels" => "2",
120+
'defaultAudioOptions' => [
121+
'audioEncoder' => 'mp3',
122+
'audioBitRate' => '128k',
123+
'audioSampleRate' => '44100',
124+
'audioChannels' => '2',
126125
],
127126

128127
];

src/console/controllers/DefaultController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22
/**
3-
* Transcoder plugin for Craft CMS 3.x
3+
* Transcode plugin for Craft CMS 3.x
44
*
5-
* Transcoder
5+
* Transcode
66
*
77
* @link https://nystudio107.com
8-
* @copyright Copyright (c) 2017 Transcoder
8+
* @copyright Copyright (c) 2017 Transcode
99
*/
1010

1111
namespace nystudio107\transcoder\console\controllers;
@@ -19,8 +19,8 @@
1919
/**
2020
* Default Command
2121
*
22-
* @author Transcoder
23-
* @package Transcoder
22+
* @author Transcode
23+
* @package Transcode
2424
* @since 1.0.0
2525
*/
2626
class DefaultController extends Controller

src/controllers/DefaultController.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
/**
2020
* @author nystudio107
21-
* @package Transcoder
21+
* @package Transcode
2222
* @since 1.0.0
2323
*/
2424
class DefaultController extends Controller
@@ -34,7 +34,7 @@ class DefaultController extends Controller
3434
*/
3535
protected $allowAnonymous = [
3636
'download-file',
37-
'progress'
37+
'progress',
3838
];
3939

4040
// Public Methods
@@ -49,7 +49,7 @@ class DefaultController extends Controller
4949
public function actionDownloadFile($url)
5050
{
5151
$filePath = parse_url($url, PHP_URL_PATH);
52-
$filePath = $_SERVER['DOCUMENT_ROOT'].$filePath;
52+
$filePath = $_SERVER['DOCUMENT_ROOT'] . $filePath;
5353
Craft::$app->getResponse()->sendFile(
5454
$filePath,
5555
null,
@@ -73,7 +73,7 @@ public function actionDownloadFile($url)
7373
public function actionProgress($filename)
7474
{
7575
$result = [];
76-
$progressFile = sys_get_temp_dir().DIRECTORY_SEPARATOR.$filename.".progress";
76+
$progressFile = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename . ".progress";
7777
if (file_exists($progressFile)) {
7878
$content = @file_get_contents($progressFile);
7979
if ($content) {
@@ -117,7 +117,7 @@ public function actionProgress($filename)
117117
$result = [
118118
'filename' => $filename,
119119
'duration' => $duration,
120-
'time' => $time,
120+
'time' => $time,
121121
'progress' => $progress,
122122
];
123123
}

0 commit comments

Comments
 (0)