-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix circular dependency issue with configs using environment variables
The issue was introduced with nette/di update. The generated code changed in a way that the circular dependency started appearing. The easiest solution was to get rid of "setup" method of EnvironmentConfig service and extract the configs to specific classes. remp/remp#1299
- Loading branch information
Showing
11 changed files
with
123 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
Mailer/extensions/mailer-module/src/Models/Config/EditorConfig.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Remp\MailerModule\Models\Config; | ||
|
||
class EditorConfig | ||
{ | ||
public const EDITOR_CODEMIRROR = 'codemirror'; | ||
public const EDITOR_WYSIWYG = 'wysiwyg'; | ||
|
||
private string $templateEditor = self::EDITOR_CODEMIRROR; | ||
|
||
public function setTemplateEditor(string $editor): void | ||
{ | ||
$this->templateEditor = match ($editor) { | ||
self::EDITOR_CODEMIRROR => self::EDITOR_CODEMIRROR, | ||
self::EDITOR_WYSIWYG => self::EDITOR_WYSIWYG, | ||
default => throw new \Exception('Unsupported editor configured: ' . $editor), | ||
}; | ||
} | ||
|
||
public function getTemplateEditor(): string | ||
{ | ||
return $this->templateEditor; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Mailer/extensions/mailer-module/src/Models/Config/LinkedServices.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Remp\MailerModule\Models\Config; | ||
|
||
class LinkedServices | ||
{ | ||
private array $linkedServices = []; | ||
|
||
public function linkService(string $code, ?string $url, ?string $icon): void | ||
{ | ||
if (empty($url)) { | ||
return; | ||
} | ||
$this->linkedServices[$code] = [ | ||
'url' => $url, | ||
'icon' => $icon, | ||
]; | ||
} | ||
|
||
public function getServices(): array | ||
{ | ||
return $this->linkedServices; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Mailer/extensions/mailer-module/src/Models/Config/SearchConfig.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Remp\MailerModule\Models\Config; | ||
|
||
class SearchConfig | ||
{ | ||
private int $maxResultCount = 5; | ||
|
||
public function setMaxResultCount(int $maxResultCount): void | ||
{ | ||
$this->maxResultCount = $maxResultCount; | ||
} | ||
|
||
public function getMaxResultCount(): int | ||
{ | ||
return $this->maxResultCount; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters