-
-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom handlers for dependency exceptions
- Loading branch information
1 parent
6147ee9
commit 7825b50
Showing
3 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/Extension/Exception/DependentExtensionsExceptionHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Extension\Exception; | ||
|
||
use Flarum\Foundation\ErrorHandling\HandledError; | ||
|
||
class DependentExtensionsExceptionHandler | ||
{ | ||
public function handle(DependentExtensionsException $e): HandledError | ||
{ | ||
return (new HandledError( | ||
$e, | ||
'dependent_extensions', | ||
409 | ||
))->withDetails($this->errorDetails($e)); | ||
} | ||
|
||
protected function errorDetails(DependentExtensionsException $e): array | ||
{ | ||
return [ | ||
[ | ||
'extension' => $e->extension->getId(), | ||
'dependent_dependencies' => $e->dependent_dependencies | ||
] | ||
]; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/Extension/Exception/MissingDependenciesExceptionHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of Flarum. | ||
* | ||
* For detailed copyright and license information, please view the | ||
* LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Flarum\Extension\Exception; | ||
|
||
use Flarum\Foundation\ErrorHandling\HandledError; | ||
|
||
class MissingDependenciesExceptionHandler | ||
{ | ||
public function handle(MissingDependenciesException $e): HandledError | ||
{ | ||
return (new HandledError( | ||
$e, | ||
'missing_dependencies', | ||
409 | ||
))->withDetails($this->errorDetails($e)); | ||
} | ||
|
||
protected function errorDetails(MissingDependenciesException $e): array | ||
{ | ||
return [ | ||
[ | ||
'extension' => $e->extension->getId(), | ||
'missing_dependencies' => $e->missing_dependencies | ||
] | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters