| @@ 24-51 (lines=28) @@ | ||
| 21 | /** |
|
| 22 | * Creates an instance of options for applications |
|
| 23 | */ |
|
| 24 | class ModuleOptionsFactory implements FactoryInterface |
|
| 25 | { |
|
| 26 | /** |
|
| 27 | * Create a ModuleOptions options |
|
| 28 | * |
|
| 29 | * @param ContainerInterface $container |
|
| 30 | * @param string $requestedName |
|
| 31 | * @param null|array $options |
|
| 32 | * |
|
| 33 | * @return ModuleOptions |
|
| 34 | * @throws ServiceNotFoundException if unable to resolve the service. |
|
| 35 | * @throws ServiceNotCreatedException if an exception is raised when |
|
| 36 | * creating a service. |
|
| 37 | * @throws ContainerException if any other error occurs |
|
| 38 | */ |
|
| 39 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
| 40 | { |
|
| 41 | $config = $container->get('Config'); |
|
| 42 | return new ModuleOptions(isset($config['application_options']) ? $config['application_options'] : array()); |
|
| 43 | } |
|
| 44 | /** |
|
| 45 | * {@inheritDoc} |
|
| 46 | */ |
|
| 47 | public function createService(ServiceLocatorInterface $serviceLocator) |
|
| 48 | { |
|
| 49 | return $this($serviceLocator, ModuleOptions::class); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 25-58 (lines=34) @@ | ||
| 22 | * Class ModuleOptionsFactory |
|
| 23 | * @package Core\Factory |
|
| 24 | */ |
|
| 25 | class ModuleOptionsFactory implements FactoryInterface |
|
| 26 | { |
|
| 27 | /** |
|
| 28 | * Create an object |
|
| 29 | * |
|
| 30 | * @param ContainerInterface $container |
|
| 31 | * @param string $requestedName |
|
| 32 | * @param null|array $options |
|
| 33 | * |
|
| 34 | * @return object |
|
| 35 | * @throws ServiceNotFoundException if unable to resolve the service. |
|
| 36 | * @throws ServiceNotCreatedException if an exception is raised when |
|
| 37 | * creating a service. |
|
| 38 | * @throws ContainerException if any other error occurs |
|
| 39 | */ |
|
| 40 | public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
|
| 41 | { |
|
| 42 | $config = $container->get('Config'); |
|
| 43 | ||
| 44 | return new ModuleOptions(isset($config['core_options']) ? $config['core_options'] : array()); |
|
| 45 | } |
|
| 46 | ||
| 47 | ||
| 48 | /** |
|
| 49 | * {@inheritDoc} |
|
| 50 | * |
|
| 51 | * @param ServiceLocatorInterface $serviceLocator |
|
| 52 | * @return ModuleOptions |
|
| 53 | */ |
|
| 54 | public function createService(ServiceLocatorInterface $serviceLocator) |
|
| 55 | { |
|
| 56 | return $this($serviceLocator, ModuleOptions::class); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||