| @@ 20-46 (lines=27) @@ | ||
| 17 | * |
|
| 18 | * @package Nnx\JmsSerializerModule\NamingStrategy |
|
| 19 | */ |
|
| 20 | class CacheNamingStrategyFactory implements FactoryInterface, MutableCreationOptionsInterface |
|
| 21 | { |
|
| 22 | use MutableCreationOptionsTrait; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @param ServiceLocatorInterface $serviceLocator |
|
| 26 | * |
|
| 27 | * @return CacheNamingStrategy |
|
| 28 | * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
|
| 29 | * @throws \Nnx\JmsSerializerModule\NamingStrategy\Exception\RuntimeException |
|
| 30 | */ |
|
| 31 | public function createService(ServiceLocatorInterface $serviceLocator) |
|
| 32 | { |
|
| 33 | $creationOptions = $this->getCreationOptions(); |
|
| 34 | ||
| 35 | if (!array_key_exists('delegate', $creationOptions)) { |
|
| 36 | $errMsg = 'Delegate naming strategy not specified'; |
|
| 37 | throw new Exception\RuntimeException($errMsg); |
|
| 38 | } |
|
| 39 | $delegateName = $creationOptions['delegate']; |
|
| 40 | ||
| 41 | /** @var PropertyNamingStrategyInterface $delegate */ |
|
| 42 | $delegate = $serviceLocator->get($delegateName); |
|
| 43 | ||
| 44 | return new CacheNamingStrategy($delegate); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||
| @@ 20-46 (lines=27) @@ | ||
| 17 | * |
|
| 18 | * @package Nnx\JmsSerializerModule\NamingStrategy |
|
| 19 | */ |
|
| 20 | class SerializedNameAnnotationStrategyFactory implements FactoryInterface, MutableCreationOptionsInterface |
|
| 21 | { |
|
| 22 | use MutableCreationOptionsTrait; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @param ServiceLocatorInterface $serviceLocator |
|
| 26 | * |
|
| 27 | * @return SerializedNameAnnotationStrategy |
|
| 28 | * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
|
| 29 | * @throws \Nnx\JmsSerializerModule\NamingStrategy\Exception\RuntimeException |
|
| 30 | */ |
|
| 31 | public function createService(ServiceLocatorInterface $serviceLocator) |
|
| 32 | { |
|
| 33 | $creationOptions = $this->getCreationOptions(); |
|
| 34 | ||
| 35 | if (!array_key_exists('delegate', $creationOptions)) { |
|
| 36 | $errMsg = 'Delegate naming strategy not specified'; |
|
| 37 | throw new Exception\RuntimeException($errMsg); |
|
| 38 | } |
|
| 39 | $delegateName = $creationOptions['delegate']; |
|
| 40 | ||
| 41 | /** @var PropertyNamingStrategyInterface $delegate */ |
|
| 42 | $delegate = $serviceLocator->get($delegateName); |
|
| 43 | ||
| 44 | return new SerializedNameAnnotationStrategy($delegate); |
|
| 45 | } |
|
| 46 | } |
|
| 47 | ||