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

Integration with package Ziggy has been implemented #64

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog][keepachangelog] and this project adheres to [Semantic Versioning][semver].

## UNRELEASED

### Added

- Integration with [Ziggy](https://github.com/tighten/ziggy) is supported now (just enable `ResetZiggyListener` for `BeforeLoopIterationEvent`)

## v5.2.2

### Changed
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 @@ -40,6 +40,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();
}
}