Container.php
126 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AmeliaBooking\Infrastructure\Common; |
| 4 | |
| 5 | use AmeliaBooking\Domain\Repository\User\UserRepositoryInterface; |
| 6 | use AmeliaBooking\Domain\Services\Logger\LoggerInterface; |
| 7 | use AmeliaBooking\Infrastructure\Connection; |
| 8 | use AmeliaVendor\Psr\Container\ContainerInterface; |
| 9 | use Pimple\Container as PimpleContainer; |
| 10 | |
| 11 | /** |
| 12 | * Class Container |
| 13 | * |
| 14 | * @package AmeliaBooking\Infrastructure\Common |
| 15 | */ |
| 16 | final class Container extends PimpleContainer implements ContainerInterface |
| 17 | { |
| 18 | public function get(string $id) |
| 19 | { |
| 20 | return $this->offsetGet($id); |
| 21 | } |
| 22 | |
| 23 | public function has(string $id): bool |
| 24 | { |
| 25 | return $this->offsetExists($id); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @return Connection |
| 30 | */ |
| 31 | public function getDatabaseConnection() |
| 32 | { |
| 33 | return $this->get('app.connection'); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @return UserRepositoryInterface |
| 38 | */ |
| 39 | public function getUserRepository() |
| 40 | { |
| 41 | return $this->get('domain.users.repository'); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Get the command bus |
| 46 | * |
| 47 | * @return mixed |
| 48 | */ |
| 49 | public function getCommandBus() |
| 50 | { |
| 51 | return $this->get('command.bus'); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Get the event bus |
| 56 | * |
| 57 | * @return mixed |
| 58 | */ |
| 59 | public function getEventBus() |
| 60 | { |
| 61 | return $this->get('domain.event.bus'); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Get the Permissions domain service |
| 66 | * |
| 67 | */ |
| 68 | public function getPermissionsService() |
| 69 | { |
| 70 | return $this->get('domain.permissions.service'); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Get the API Permissions domain service |
| 75 | * |
| 76 | */ |
| 77 | public function getApiPermissionsService() |
| 78 | { |
| 79 | return $this->get('domain.api.permissions.service'); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Get the API User application service |
| 84 | * |
| 85 | */ |
| 86 | public function getApiUserApplicationService() |
| 87 | { |
| 88 | return $this->get('application.api.user.service'); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Get the User application service |
| 93 | * |
| 94 | */ |
| 95 | public function getUserApplicationService() |
| 96 | { |
| 97 | return $this->get('application.user.service'); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Get the Logger service |
| 102 | * |
| 103 | * @return LoggerInterface |
| 104 | */ |
| 105 | public function getLoggerService() |
| 106 | { |
| 107 | return $this->get('infrastructure.logger'); |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * @return mixed |
| 112 | */ |
| 113 | public function getMailerService() |
| 114 | { |
| 115 | return $this->get('application.mailer'); |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * @return mixed |
| 120 | */ |
| 121 | public function getSettingsService() |
| 122 | { |
| 123 | return $this->get('domain.settings.service'); |
| 124 | } |
| 125 | } |
| 126 |