|
1 | 1 | <?php |
2 | 2 |
|
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/** |
| 6 | + * This file is part of php-fast-forward/framework. |
| 7 | + * |
| 8 | + * This source file is subject to the license bundled |
| 9 | + * with this source code in the file LICENSE. |
| 10 | + * |
| 11 | + * @link https://github.com/php-fast-forward/framework |
| 12 | + * @copyright Copyright (c) 2025 Felipe Sayão Lobato Abreu <[email protected]> |
| 13 | + * @license https://opensource.org/licenses/MIT MIT License |
| 14 | + */ |
| 15 | + |
3 | 16 | namespace FastForward\Framework\ServiceProvider; |
4 | 17 |
|
5 | 18 | use FastForward\Container\ServiceProvider\AggregateServiceProvider; |
6 | | -use FastForward\EventDispatcher\ServiceProvider\EventDispatcherServiceProvider; |
7 | 19 | use FastForward\Http\ServiceProvider\HttpServiceProvider; |
8 | 20 | use Interop\Container\ServiceProviderInterface; |
9 | 21 |
|
| 22 | +/** |
| 23 | + * Class FrameworkServiceProvider. |
| 24 | + * |
| 25 | + * Aggregates core framework service providers into a unified service provider. |
| 26 | + * This class MUST be used to encapsulate all foundational service providers |
| 27 | + * required to initialize the application container. |
| 28 | + * |
| 29 | + * The internal aggregation MAY include HTTP, logging, caching, console, |
| 30 | + * event dispatching, session handling, and other service providers required |
| 31 | + * for application infrastructure. |
| 32 | + * |
| 33 | + * This class SHALL implement the ServiceProviderInterface and MUST delegate |
| 34 | + * its service discovery responsibilities to an internal AggregateServiceProvider. |
| 35 | + */ |
10 | 36 | final class FrameworkServiceProvider implements ServiceProviderInterface |
11 | 37 | { |
| 38 | + /** |
| 39 | + * @var ServiceProviderInterface the aggregate container for framework service providers |
| 40 | + */ |
12 | 41 | private ServiceProviderInterface $serviceProvider; |
13 | 42 |
|
| 43 | + /** |
| 44 | + * Constructs the FrameworkServiceProvider. |
| 45 | + * |
| 46 | + * This constructor MUST initialize the aggregate service provider using |
| 47 | + * a composition of essential framework service providers. |
| 48 | + */ |
14 | 49 | public function __construct() |
15 | 50 | { |
16 | 51 | $this->serviceProvider = new AggregateServiceProvider( |
17 | 52 | new HttpServiceProvider(), |
18 | | - new EventDispatcherServiceProvider(), |
| 53 | + // ErrorHandlerServiceProvider, |
| 54 | + // EventDispatcherServiceProvider, |
| 55 | + // LoggerServiceProvider, |
| 56 | + // CacheServiceProvider, |
| 57 | + // ConsoleServiceProvider, |
| 58 | + // TemplateRendererServiceProvider, |
| 59 | + // SecurityServiceProvider, |
| 60 | + // SessionServiceProvider, |
| 61 | + // ... |
19 | 62 | ); |
20 | 63 | } |
21 | 64 |
|
| 65 | + /** |
| 66 | + * Returns an array of service factory callables. |
| 67 | + * |
| 68 | + * This method MUST delegate to the internal AggregateServiceProvider and |
| 69 | + * return all service factories required for container instantiation. |
| 70 | + * |
| 71 | + * @return array<string, callable> an associative array of factory callables indexed by service IDs |
| 72 | + */ |
22 | 73 | public function getFactories(): array |
23 | 74 | { |
24 | 75 | return $this->serviceProvider->getFactories(); |
25 | 76 | } |
26 | 77 |
|
| 78 | + /** |
| 79 | + * Returns an array of service extension callables. |
| 80 | + * |
| 81 | + * This method MUST delegate to the internal AggregateServiceProvider and |
| 82 | + * return all service extensions used to decorate existing services. |
| 83 | + * |
| 84 | + * @return array<string, callable> an associative array of extension callables indexed by service IDs |
| 85 | + */ |
27 | 86 | public function getExtensions(): array |
28 | 87 | { |
29 | 88 | return $this->serviceProvider->getExtensions(); |
|
0 commit comments