| @@ 15-46 (lines=32) @@ | ||
| 12 | /** |
|
| 13 | * Provides set of rules and aliases for automatic mutations for Document and DocumentEntity fields. |
|
| 14 | */ |
|
| 15 | class MutatorsConfig extends InjectableConfig |
|
| 16 | { |
|
| 17 | use AliasTrait; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * Configuration section. |
|
| 21 | */ |
|
| 22 | const CONFIG = 'schemas/documents'; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var array |
|
| 26 | */ |
|
| 27 | protected $config = [ |
|
| 28 | 'aliases' => [], |
|
| 29 | 'mutators' => [] |
|
| 30 | ]; |
|
| 31 | ||
| 32 | /** |
|
| 33 | * Get list of mutators associated with given field type. |
|
| 34 | * |
|
| 35 | * @param string $type |
|
| 36 | * |
|
| 37 | * @return array |
|
| 38 | */ |
|
| 39 | public function getMutators(string $type): array |
|
| 40 | { |
|
| 41 | $type = $this->resolveAlias($type); |
|
| 42 | $mutators = $this->config['mutators']; |
|
| 43 | ||
| 44 | return isset($mutators[$type]) ? $mutators[$type] : []; |
|
| 45 | } |
|
| 46 | } |
|
| @@ 16-47 (lines=32) @@ | ||
| 13 | /** |
|
| 14 | * Provides set of rules and aliases for automatic mutations for Record fields. |
|
| 15 | */ |
|
| 16 | class MutatorsConfig extends InjectableConfig |
|
| 17 | { |
|
| 18 | use AliasTrait; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * Configuration section. |
|
| 22 | */ |
|
| 23 | const CONFIG = 'schemas/records'; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * @var array |
|
| 27 | */ |
|
| 28 | protected $config = [ |
|
| 29 | 'aliases' => [], |
|
| 30 | 'mutators' => [] |
|
| 31 | ]; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * Get list of mutators associated with given field type. |
|
| 35 | * |
|
| 36 | * @param string $type |
|
| 37 | * |
|
| 38 | * @return array |
|
| 39 | */ |
|
| 40 | public function getMutators(string $type): array |
|
| 41 | { |
|
| 42 | $type = $this->resolveAlias($type); |
|
| 43 | $mutators = $this->config['mutators']; |
|
| 44 | ||
| 45 | return isset($mutators[$type]) ? $mutators[$type] : []; |
|
| 46 | } |
|
| 47 | } |
|
| 48 | ||