2222 */
2323class Settings extends Model
2424{
25-
2625 // Static Methods
2726 // =========================================================================
2827
29- /**
30- * @inheritdoc
31- */
32- public function __construct (array $ config = [])
33- {
34- // Unset any deprecated properties
35- if (!empty ($ config )) {
36- // If the old properties are set, remap them to the default
37- if (isset ($ config ['transcoderPath ' ])) {
38- $ config ['transcoderPaths ' ]['default ' ] = $ config ['transcoderPath ' ];
39- unset($ config ['transcoderPath ' ]);
40- }
41- if (isset ($ config ['transcoderUrl ' ])) {
42- $ config ['$transcoderUrls ' ]['default ' ] = $ config ['transcoderUrl ' ];
43- unset($ config ['transcoderUrl ' ]);
44- }
45- }
46- parent ::__construct ($ config );
47- }
48-
49- // Public Properties
50- // =========================================================================
51-
5228 /**
5329 * The path to the ffmpeg binary
5430 *
5531 * @var string
5632 */
5733 public $ ffmpegPath = '/usr/bin/ffmpeg ' ;
5834
35+ // Public Properties
36+ // =========================================================================
5937 /**
6038 * The path to the ffprobe binary
6139 *
6240 * @var string
6341 */
6442 public $ ffprobePath = '/usr/bin/ffprobe ' ;
65-
6643 /**
6744 * The options to use for ffprobe
6845 *
6946 * @var string
7047 */
7148 public $ ffprobeOptions = '-v quiet -print_format json -show_format -show_streams ' ;
72-
7349 /**
7450 * The path where the transcoded videos are stored; must have a trailing /
7551 * Yii2 aliases are supported here
@@ -83,7 +59,6 @@ public function __construct(array $config = [])
8359 'thumbnail ' => '@webroot/transcoder/ ' ,
8460 'gif ' => '@webroot/transcoder/ ' ,
8561 ];
86-
8762 /**
8863 * The URL where the transcoded videos are stored; must have a trailing /
8964 * Yii2 aliases are supported here
@@ -97,14 +72,25 @@ public function __construct(array $config = [])
9772 'thumbnail ' => '@web/transcoder/ ' ,
9873 'gif ' => '@web/transcoder/ ' ,
9974 ];
100-
10175 /**
10276 * Use a md5 hash for the filenames instead of parameterized naming
10377 *
10478 * @var bool
10579 */
10680 public $ useHashedNames = false ;
107-
81+ /**
82+ * if a upload location has a subfolder defined, add this to the transcoder
83+ * paths too
84+ *
85+ * @var bool
86+ */
87+ public $ createSubfolders = true ;
88+ /**
89+ * clear caches when somebody clears all caches from the CP?
90+ *
91+ * @var bool
92+ */
93+ public $ clearCaches = false ;
10894 /**
10995 * Preset video encoders
11096 *
@@ -137,7 +123,6 @@ public function __construct(array $config = [])
137123 'threads ' => '0 ' ,
138124 ],
139125 ];
140-
141126 /**
142127 * Preset audio encoders
143128 *
@@ -167,7 +152,6 @@ public function __construct(array $config = [])
167152 'threads ' => '0 ' ,
168153 ],
169154 ];
170-
171155 /**
172156 * Default options for encoded videos
173157 *
@@ -190,7 +174,6 @@ public function __construct(array $config = [])
190174 'aspectRatio ' => 'letterbox ' ,
191175 'letterboxColor ' => '' ,
192176 ];
193-
194177 /**
195178 * Default options for video thumbnails
196179 *
@@ -206,7 +189,6 @@ public function __construct(array $config = [])
206189 'aspectRatio ' => 'letterbox ' ,
207190 'letterboxColor ' => '' ,
208191 ];
209-
210192 /**
211193 * Default options for encoded videos
212194 *
@@ -218,7 +200,6 @@ public function __construct(array $config = [])
218200 'audioSampleRate ' => '44100 ' ,
219201 'audioChannels ' => '2 ' ,
220202 ];
221-
222203 /**
223204 * Default options for encoded GIF
224205 *
@@ -232,6 +213,26 @@ public function __construct(array $config = [])
232213 'videoCodecOptions ' => '' ,
233214 ];
234215
216+ /**
217+ * @inheritdoc
218+ */
219+ public function __construct (array $ config = [])
220+ {
221+ // Unset any deprecated properties
222+ if (!empty ($ config )) {
223+ // If the old properties are set, remap them to the default
224+ if (isset ($ config ['transcoderPath ' ])) {
225+ $ config ['transcoderPaths ' ]['default ' ] = $ config ['transcoderPath ' ];
226+ unset($ config ['transcoderPath ' ]);
227+ }
228+ if (isset ($ config ['transcoderUrl ' ])) {
229+ $ config ['$transcoderUrls ' ]['default ' ] = $ config ['transcoderUrl ' ];
230+ unset($ config ['transcoderUrl ' ]);
231+ }
232+ }
233+ parent ::__construct ($ config );
234+ }
235+
235236 // Public Methods
236237 // =========================================================================
237238
@@ -260,9 +261,9 @@ public function rules()
260261 ['transcoderPaths ' , ArrayValidator::class],
261262 ['transcoderPaths ' , 'required ' ],
262263 ['transcoderUrls ' , ArrayValidator::class],
263- ['transcoderUrls ' , 'required ' ],
264264 ['useHashedNames ' , 'boolean ' ],
265- ['useHashedNames ' , 'default ' , 'value ' => false ],
265+ ['createSubfolders ' , 'boolean ' ],
266+ ['clearCaches ' , 'boolean ' ],
266267 ['videoEncoders ' , 'required ' ],
267268 ['audioEncoders ' , 'required ' ],
268269 ['defaultVideoOptions ' , 'required ' ],
0 commit comments