-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from Ricorocks-Digital-Agency/ray-support
Adds support for Spatie's Ray library
- Loading branch information
Showing
6 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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,48 @@ | ||
<?php | ||
|
||
|
||
namespace RicorocksDigitalAgency\Soap\Ray; | ||
|
||
use RicorocksDigitalAgency\Soap\Facades\Soap; | ||
use RicorocksDigitalAgency\Soap\Request\Request; | ||
use RicorocksDigitalAgency\Soap\Response\Response; | ||
use Spatie\LaravelRay\Ray; | ||
use Spatie\LaravelRay\Watchers\Watcher; | ||
use Spatie\Ray\Ray as SpatieRay; | ||
|
||
class SoapWatcher extends Watcher | ||
{ | ||
public static function rayExists(): bool | ||
{ | ||
return class_exists("Spatie\\Ray\\Ray"); | ||
} | ||
|
||
public function register(): void | ||
{ | ||
SpatieRay::macro('showSoapRequests', fn() => app(SoapWatcher::class)->enable()); | ||
SpatieRay::macro('stopShowingSoapRequests', fn() => app(SoapWatcher::class)->disable()); | ||
|
||
Soap::afterRequesting( | ||
function ($request, $response) { | ||
if (!app(SoapWatcher::class)->enabled()) { | ||
return; | ||
} | ||
|
||
$this->handleRequest($request, $response); | ||
} | ||
); | ||
} | ||
|
||
protected function handleRequest(Request $request, Response $response) | ||
{ | ||
app(Ray::class)->table( | ||
[ | ||
'Endpoint' => $request->getEndpoint(), | ||
'Method' => $request->getMethod(), | ||
'Request' => $request->getBody(), | ||
'Response' => $response->response, | ||
], | ||
"SOAP" | ||
); | ||
} | ||
} |
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
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