Skip to content

Commit f1fd549

Browse files
committed
Added public Translate class to WebAppService
1 parent fd74b29 commit f1fd549

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- `Fixed` for any bug fixes.
1414
- `Security` in case of vulnerabilities
1515

16+
## [1.4.0] - 2025.01.10
17+
18+
### Added
19+
20+
Added public `Translate` class to `WebAppService`
21+
1622
## [1.3.0] - 2025.01.19
1723

1824
### Added

docs/setup.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This service requires the following Bones services to exist in the container:
1414

1515
In addition, this service also requires the following library to exist in the container:
1616

17-
- [Translate](https://github.com/bayfrontmedia/translation)
17+
- [Translation](https://github.com/bayfrontmedia/translation)
1818

1919
The default locale used in the `Translate` class constructor should be set
2020
to the `webapp.locale.default` config value (see below).

docs/webappservice-class.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ The `WebAppService` class contains the following Bones services:
66
- [FilterService](https://github.com/bayfrontmedia/bones/blob/master/docs/services/filters.md) as `$this->filters`
77
- [Response](https://github.com/bayfrontmedia/bones/blob/master/docs/services/response.md) as `$this->response`
88
- [Router](https://github.com/bayfrontmedia/bones/blob/master/docs/services/router.md) as `$this->router`
9+
- [Translation](https://github.com/bayfrontmedia/translation) as `$this->translate`
910
- [Veil](https://github.com/bayfrontmedia/bones/blob/master/docs/services/veil.md) as `$this->veil`

src/WebAppService.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
use Bayfront\Bones\Abstracts\Service;
66
use Bayfront\Bones\Application\Services\Events\EventService;
77
use Bayfront\Bones\Application\Services\Filters\FilterService;
8-
use Bayfront\Bones\Application\Utilities\App;
98
use Bayfront\Bones\Exceptions\ServiceException;
109
use Bayfront\BonesService\WebApp\Events\WebAppServiceEvents;
1110
use Bayfront\BonesService\WebApp\Exceptions\WebAppServiceException;
1211
use Bayfront\BonesService\WebApp\Filters\WebAppServiceFilters;
13-
use Bayfront\Container\NotFoundException;
1412
use Bayfront\HttpResponse\Response;
1513
use Bayfront\RouteIt\Router;
14+
use Bayfront\Translation\Translate;
1615
use Bayfront\Veil\Veil;
1716

1817
class WebAppService extends Service
@@ -22,6 +21,7 @@ class WebAppService extends Service
2221
public FilterService $filters;
2322
public Response $response;
2423
public Router $router;
24+
public Translate $translate;
2525
public Veil $veil;
2626

2727
/**
@@ -32,30 +32,27 @@ class WebAppService extends Service
3232
* @param FilterService $filters
3333
* @param Response $response
3434
* @param Router $router
35+
* @param Translate $translate
3536
* @param Veil $veil
3637
* @throws WebAppServiceException
3738
*/
3839

39-
public function __construct(EventService $events, FilterService $filters, Response $response, Router $router, Veil $veil)
40+
public function __construct(EventService $events, FilterService $filters, Response $response, Router $router, Translate $translate, Veil $veil)
4041
{
4142
$this->events = $events;
4243
$this->filters = $filters;
4344
$this->response = $response;
4445
$this->router = $router;
46+
$this->translate = $translate;
4547
$this->veil = $veil;
4648

4749
parent::__construct($events);
4850

49-
if (!App::has('Bayfront\Translation\Translate')) {
50-
throw new WebAppServiceException('Unable to start WebAppService: Required dependency not found (Bayfront\Translation\Translate)');
51-
}
52-
5351
// Enqueue events
5452

5553
try {
56-
$translate = App::get('Bayfront\Translation\Translate');
5754
$this->events->addSubscriptions(new WebAppServiceEvents($this, $translate));
58-
} catch (ServiceException|NotFoundException $e) {
55+
} catch (ServiceException $e) {
5956
throw new WebAppServiceException('Unable to start WebAppService: ' . $e->getMessage(), $e->getCode(), $e->getPrevious());
6057
}
6158

0 commit comments

Comments
 (0)