Skip to content

Commit 4877af2

Browse files
committed
Fixed #168 unresolvable dependency in RollbarServiceProvider::boot()
1 parent 6167157 commit 4877af2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/RollbarServiceProvider.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,21 @@ public function register(): void
5454
*
5555
* This is where we can start listening for events.
5656
*
57-
* @param RollbarLogger $logger This parameter is injected by the service container, and is required to ensure that
58-
* the Rollbar logger is initialized.
5957
* @return void
6058
*
6159
* @since 8.1.0
60+
* @since 8.1.1 Changed RollbarLogger from dependency injection to service locator.
6261
*/
63-
public function boot(RollbarLogger $logger): void
62+
public function boot(): void
6463
{
64+
// Get the RollbarLogger if it is bound. This is needed and is required to ensure that the Rollbar logger is
65+
// initialized. Without this, the telemetry listener will not be able to send telemetry events.
66+
try {
67+
$logger = $this->app->make(RollbarLogger::class);
68+
} catch (BindingResolutionException $e) {
69+
// RollbarLogger is not bound, so we can't set up telemetry.
70+
return;
71+
}
6572
// Set up telemetry if it is enabled.
6673
if (null !== Rollbar::getTelemeter()) {
6774
$this->setupTelemetry($this->getConfigs($this->app));

0 commit comments

Comments
 (0)