Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ResourceCustomGlobalActionResourceButtonLabel | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| getFallbackText | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| createFromDefinition | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\Translator\ValueObjects; |
| 3 | |
| 4 | use Apie\Common\ActionDefinitions\RunResourceMethodDefinition; |
| 5 | use Apie\Core\Attributes\Description; |
| 6 | use Apie\Core\Attributes\ExampleValue; |
| 7 | use Apie\Core\Identifiers\SnakeCaseSlug; |
| 8 | use Apie\Core\Lists\ItemHashmap; |
| 9 | |
| 10 | #[Description('Label shown on button for a domain specific action')] |
| 11 | #[ExampleValue('apie.bounded.test.example.user.action.global.create_admin.label.authenticated')] |
| 12 | class ResourceCustomGlobalActionResourceButtonLabel extends AbstractTranslation |
| 13 | { |
| 14 | protected const MIDDLE_REGEX = 'action\.global\.:action\.label'; |
| 15 | |
| 16 | public function getFallbackText(): string |
| 17 | { |
| 18 | return ucfirst(SnakeCaseSlug::fromText($this->getPlaceholders()['action'] ?? 'action')); |
| 19 | } |
| 20 | |
| 21 | public static function createFromDefinition(RunResourceMethodDefinition $actionDefinition, ?bool $authenticated): static |
| 22 | { |
| 23 | $action = SnakeCaseSlug::fromClass($actionDefinition->getMethod()); |
| 24 | return new static( |
| 25 | new TranslationStringPrefix( |
| 26 | $actionDefinition->getBoundedContextId(), |
| 27 | SnakeCaseSlug::fromClass($actionDefinition->getResourceName()) |
| 28 | ), |
| 29 | 'action.global.' . $action . '.label', |
| 30 | new TranslationStringSuffix(null, $authenticated), |
| 31 | new ItemHashmap(['action' => $action]) |
| 32 | ); |
| 33 | } |
| 34 | } |