Skip to content

Commit 68554d3

Browse files
committed
fix: autowiring
1 parent 3b7bc5a commit 68554d3

6 files changed

Lines changed: 20 additions & 17 deletions

File tree

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,25 @@ When a health check failed the HTTP Response status code will be 503. And the JS
2929
composer require openconext/monitor-bundle
3030
```
3131

32-
* Add the bundle to your kernel in `app/AppKernel.php`
32+
* If you don't use [Symfony Flex](https://symfony.com/doc/current/setup/flex.html), you must enable the bundle manually in the application:
33+
3334
```php
34-
public function registerBundles()
35-
{
36-
// ...
37-
new OpenConext\MonitorBundle\OpenConextMonitorBundle(),
38-
}
39-
```
35+
// config/bundles.php
36+
// in older Symfony apps, enable the bundle in app/AppKernel.php
37+
return [
38+
// ...
39+
OpenConext\MonitorBundle\OpenConextMonitorBundle::class => ['all' => true],
40+
];
41+
```
4042
41-
* Include the routing configuration in `app/config/routing.yml` by adding:
43+
* Include the routing configuration in `config/routes.yml` by adding:
4244
```yaml
43-
openconext_monitor:
45+
open_conext_monitor:
4446
resource: "@OpenConextMonitorBundle/Resources/config/routing.yml"
4547
prefix: /
4648
```
4749
48-
* Add security exceptions in `app/config/security.yml` (if this is required at all)
50+
* Add security exceptions in `config/security.yml` (if this is required at all)
4951
```yaml
5052
security:
5153
firewalls:

src/Controller/HealthController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(HealthCheckChain $healthChecker)
4040
$this->healthChecker = $healthChecker;
4141
}
4242

43-
public function healthAction(): JsonResponse
43+
public function __invoke(): JsonResponse
4444
{
4545
$statusResponse = $this->healthChecker->check();
4646

src/Controller/InfoController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function __construct(
6666
$this->debuggerEnabled = $debuggerEnabled;
6767
}
6868

69-
public function infoAction(): JsonResponse
69+
public function __invoke(): JsonResponse
7070
{
7171
$info = Information::buildFrom(
7272
BuildPathFactory::buildFrom($this->buildPath),

src/HealthCheck/DoctrineConnectionHealthCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function check(HealthReportInterface $report): HealthReportInterface
5555
$table = reset($tables);
5656
// Perform a light-weight query on the chosen table
5757
$query = 'SELECT * FROM `%s` LIMIT 1';
58-
$this->entityManager->getConnection()->query(sprintf($query, $table->getName()));
58+
$this->entityManager->getConnection()->executeQuery(sprintf($query, $table->getName()));
5959
}
6060
} catch (Exception $e) {
6161
return HealthReport::buildStatusDown('Unable to execute a query on the database.');

src/Resources/config/routing.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ monitor.info:
22
path: /info
33
methods: [GET]
44
defaults:
5-
_controller: openconext.monitor.controller.info:infoAction
5+
_controller: openconext.monitor.controller.info
66

77
monitor.health:
88
path: /health
99
methods: [GET]
1010
defaults:
11-
_controller: openconext.monitor.controller.health:healthAction
11+
_controller: openconext.monitor.controller.health

src/Resources/config/services.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ services:
66
- '%kernel.environment%'
77
- '%kernel.debug%'
88
public: true
9-
tags: ['controller.service_arguments']
9+
autowire: true
10+
tags: ['controller.service_arguments', 'container.service_subscriber']
1011

1112
openconext.monitor.controller.health:
1213
class: OpenConext\MonitorBundle\Controller\HealthController
1314
arguments:
1415
- '@openconext.monitor.health_check_chain'
1516
public: true
16-
tags: ['controller.service_arguments']
17+
tags: ['controller.service_arguments', 'container.service_subscriber']
1718

1819
openconext.monitor.health_check_chain:
1920
class: OpenConext\MonitorBundle\HealthCheck\HealthCheckChain

0 commit comments

Comments
 (0)