Skip to content

Commit 96cb930

Browse files
committed
chore: Separate RequiredSettingException to own file
1 parent 1d5ac94 commit 96cb930

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

core/components/modai/lexicon/en/default.inc.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,4 @@
109109
$_lang['modai.error.failed_to_fetch_image'] = 'Failed to fetch image';
110110
$_lang['modai.error.source_not_found'] = 'MediaSource not found.';
111111
$_lang['modai.error.source_init failed'] = 'Failed to init MediaSource.';
112+
$_lang['modai.error.system_setting_required'] = 'System setting `[[+setting]]` is required.';

core/components/modai/src/API/Download/Image.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ public function post(ServerRequestInterface $request): void
5555
throw new LexiconException('modai.error.image_download_domain');
5656
}
5757

58-
5958
if (is_int($mediaSource) || ctype_digit((string)$mediaSource)) {
6059
$source = $this->modx->getObject(modMediaSource::class, [
6160
'id' => (int)$mediaSource,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
namespace modAI\Exceptions;
3+
4+
use Throwable;
5+
6+
class RequiredSettingException extends LexiconException {
7+
public function __construct($setting = "", $code = 0, Throwable $previous = null)
8+
{
9+
parent::__construct('modai.error.system_setting_required', ['setting' => $setting], $code, $previous);
10+
}
11+
}

core/components/modai/src/Settings.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
<?php
22
namespace modAI;
33

4+
use modAI\Exceptions\RequiredSettingException;
45
use MODX\Revolution\modX;
56

6-
class RequiredSettingException extends \Exception {
7-
public function __construct(string $setting)
8-
{
9-
parent::__construct("System setting `$setting` is required.");
10-
}
11-
}
12-
137
class Settings {
148
private static function getOption(modX $modx, string $namespace, string $field, string $area, string $setting): ?string
159
{

core/components/modai/src/Utils.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public static function explodeAndClean(string $stringArray, string $delimiter =
1616
return array_filter($array);
1717
}
1818

19+
/**
20+
* @param $dataURL
21+
* @return array|mixed
22+
* @throws LexiconException
23+
*/
1924
public static function parseDataURL($dataURL) {
2025
if (strpos($dataURL, 'data:') !== 0) {
2126
return $dataURL;

0 commit comments

Comments
 (0)