Skip to content

Commit

Permalink
Merge pull request #40 from andreaselia/fix/backwards-compatibility-r…
Browse files Browse the repository at this point in the history
…outeaction

backwards compatibility route action
  • Loading branch information
andreaselia authored Aug 12, 2021
2 parents 0221cc0 + dcd41c7 commit def45c6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Commands/ExportPostmanCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Illuminate\Console\Command;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Routing\RouteAction;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
Expand Down Expand Up @@ -142,7 +141,7 @@ public function handle(): void
protected function getReflectionMethod(array $routeAction): ?object
{
// Hydrates the closure if it is an instance of Opis\Closure\SerializableClosure
if (RouteAction::containsSerializedClosure($routeAction)) {
if ($this->containsSerializedClosure($routeAction)) {
$routeAction['uses'] = unserialize($routeAction['uses'])->getClosure();
}

Expand All @@ -160,6 +159,12 @@ protected function getReflectionMethod(array $routeAction): ?object
return $reflection->getMethod($routeData[1]);
}

public static function containsSerializedClosure(array $action): bool
{
return is_string($action['uses']) &&
Str::startsWith($action['uses'], 'C:32:"Opis\\Closure\\SerializableClosure') !== false;
}

protected function buildTree(array &$routes, array $segments, array $request): void
{
$parent = &$routes;
Expand Down

0 comments on commit def45c6

Please sign in to comment.