Skip to content

Commit 3912394

Browse files
committed
fix(laravel): register error handler without graphql
see api-platform/api-platform#2885
1 parent f789860 commit 3912394

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/Laravel/ApiPlatformProvider.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,26 @@ public function register(): void
927927
return new Inflector();
928928
});
929929

930+
$this->app->singleton(
931+
ExceptionHandlerInterface::class,
932+
function (Application $app) {
933+
/** @var ConfigRepository */
934+
$config = $app['config'];
935+
936+
return new ErrorHandler(
937+
$app,
938+
$app->make(ResourceMetadataCollectionFactoryInterface::class),
939+
$app->make(ApiPlatformController::class),
940+
$app->make(IdentifiersExtractorInterface::class),
941+
$app->make(ResourceClassResolverInterface::class),
942+
$app->make(Negotiator::class),
943+
$config->get('api-platform.exception_to_status'),
944+
$config->get('app.debug'),
945+
$config->get('api-platform.error_formats')
946+
);
947+
}
948+
);
949+
930950
if ($this->app->runningInConsole()) {
931951
$this->commands([
932952
Console\InstallCommand::class,
@@ -1148,26 +1168,6 @@ private function registerGraphQl(): void
11481168
formats: $config->get('api-platform.formats')
11491169
);
11501170
});
1151-
1152-
$this->app->singleton(
1153-
ExceptionHandlerInterface::class,
1154-
function (Application $app) {
1155-
/** @var ConfigRepository */
1156-
$config = $app['config'];
1157-
1158-
return new ErrorHandler(
1159-
$app,
1160-
$app->make(ResourceMetadataCollectionFactoryInterface::class),
1161-
$app->make(ApiPlatformController::class),
1162-
$app->make(IdentifiersExtractorInterface::class),
1163-
$app->make(ResourceClassResolverInterface::class),
1164-
$app->make(Negotiator::class),
1165-
$config->get('api-platform.exception_to_status'),
1166-
$config->get('app.debug'),
1167-
$config->get('api-platform.error_formats')
1168-
);
1169-
}
1170-
);
11711171
}
11721172

11731173
/**

0 commit comments

Comments
 (0)