Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into different-worker-types
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam authored Sep 30, 2021
2 parents be9a5ca + 7e7cf60 commit 9c61320
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher
### Added

- Possibility to use different classes of workers for different worker modes
- Integration with [Ziggy](https://github.com/tighten/ziggy) is supported now (just enable `ResetZiggyListener` for `BeforeLoopIterationEvent`)

## v5.2.2

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"require-dev": {
"guzzlehttp/guzzle": "^6.3 || ~7.0",
"inertiajs/inertia-laravel": "^0.4.2",
"tightenco/ziggy": "^1.4.0",
"laravel/laravel": "~6.0 || ~7.0 || ~8.0",
"laravel/scout": "~8.0 || ~9.0",
"laravel/socialite": "^5.0",
Expand Down
1 change: 1 addition & 0 deletions config/roadrunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
// Listeners\ResetLaravelScoutListener::class, // for <https://github.com/laravel/scout>
// Listeners\ResetLaravelSocialiteListener::class, // for <https://github.com/laravel/socialite>
// Listeners\ResetInertiaListener::class, // for <https://github.com/inertiajs/inertia-laravel>
// Listeners\ResetZiggyListener::class, // for <https://github.com/tighten/ziggy>
],

Events\BeforeRequestHandlingEvent::class => [
Expand Down
27 changes: 27 additions & 0 deletions src/Listeners/ResetZiggyListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Spiral\RoadRunnerLaravel\Listeners;

use Tightenco\Ziggy\BladeRouteGenerator;

/**
* Target package: <https://github.com/tighten/ziggy>.
*/
class ResetZiggyListener implements ListenerInterface
{
use Traits\InvokerTrait;

/**
* {@inheritdoc}
*/
public function handle($event): void
{
if (!\class_exists(BladeRouteGenerator::class)) {
return;
}

BladeRouteGenerator::$generated = false;
}
}
34 changes: 34 additions & 0 deletions tests/Unit/Listeners/ResetZiggyListenerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Spiral\RoadRunnerLaravel\Tests\Unit\Listeners;

use Tightenco\Ziggy\BladeRouteGenerator;
use Spiral\RoadRunnerLaravel\Listeners\ResetZiggyListener;

/**
* @covers \Spiral\RoadRunnerLaravel\Listeners\ResetZiggyListener
*/
class ResetZiggyListenerTest extends AbstractListenerTestCase
{
/**
* {@inheritdoc}
*/
public function testHandle(): void
{
BladeRouteGenerator::$generated = true;

$this->listenerFactory()->handle(new \stdClass());

$this->assertFalse(BladeRouteGenerator::$generated);
}

/**
* @return ResetZiggyListener
*/
protected function listenerFactory(): ResetZiggyListener
{
return new ResetZiggyListener();
}
}

0 comments on commit 9c61320

Please sign in to comment.