File tree Expand file tree Collapse file tree 5 files changed +96
-3
lines changed
Expand file tree Collapse file tree 5 files changed +96
-3
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,11 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher
88
99### Added
1010
11- - Listener ` FlushTranslatorCacheListener ` for memory leak fixing on ` Translator ` implementation [ #69 ]
11+ - Listener ` FlushTranslatorCacheListener ` for memory leak fixing on ` Translator ` implementation [ #70 ]
12+ - Integration with [ Livewire] ( https://github.com/livewire/livewire ) is supported now [ #71 ]
1213
13- [ #69 ] :https://github.com/spiral/roadrunner-laravel/pull/69
14+ [ #70 ] :https://github.com/spiral/roadrunner-laravel/pull/70
15+ [ #71 ] :https://github.com/spiral/roadrunner-laravel/pull/71
1416
1517## v5.4.0
1618
Original file line number Diff line number Diff line change 5050 "laravel/telescope" : " ^4.5" ,
5151 "mockery/mockery" : " ^1.3.2" ,
5252 "phpstan/phpstan" : " ~0.12.80" ,
53- "phpunit/phpunit" : " ^8.0 || ^9.3"
53+ "phpunit/phpunit" : " ^8.0 || ^9.3" ,
54+ "livewire/livewire" : " ^2.7"
5455 },
5556 "autoload" : {
5657 "psr-4" : {
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ public static function beforeLoopIteration(): array
5555 Listeners \ResetLaravelSocialiteListener::class, // for <https://github.com/laravel/socialite>
5656 Listeners \ResetInertiaListener::class, // for <https://github.com/inertiajs/inertia-laravel>
5757 Listeners \ResetZiggyListener::class, // for <https://github.com/tighten/ziggy>
58+ Listeners \ResetLivewireListener::class, // for <https://github.com/livewire/livewire>
5859 ];
5960 }
6061
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Spiral \RoadRunnerLaravel \Listeners ;
6+
7+ use Livewire \LivewireManager ;
8+ use Spiral \RoadRunnerLaravel \Events \Contracts \WithApplication ;
9+
10+ /**
11+ * Target package: <https://github.com/livewire/livewire>.
12+ */
13+ class ResetLivewireListener implements ListenerInterface
14+ {
15+ /**
16+ * {@inheritdoc}
17+ */
18+ public function handle ($ event ): void
19+ {
20+ if (!\class_exists (LivewireManager::class)) {
21+ return ;
22+ }
23+
24+ if ($ event instanceof WithApplication) {
25+ $ app = $ event ->application ();
26+
27+ if (!$ app ->resolved ($ manager_abstract = LivewireManager::class)) {
28+ return ;
29+ }
30+
31+ /** @var LivewireManager $manager */
32+ $ manager = $ app ->make ($ manager_abstract );
33+
34+ if (\method_exists ($ manager , 'flushState ' )) {
35+ $ manager ->flushState ();
36+ }
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Spiral \RoadRunnerLaravel \Tests \Unit \Listeners ;
6+
7+ use Mockery as m ;
8+ use Livewire \LivewireManager ;
9+ use Spiral \RoadRunnerLaravel \Listeners \ResetLivewireListener ;
10+ use Spiral \RoadRunnerLaravel \Events \Contracts \WithApplication ;
11+
12+ /**
13+ * @covers \Spiral\RoadRunnerLaravel\Listeners\ResetLivewireListener
14+ */
15+ class ResetLivewireListenerTest extends AbstractListenerTestCase
16+ {
17+ /**
18+ * {@inheritdoc}
19+ */
20+ public function testHandle (): void
21+ {
22+ /** @var LivewireManager $manager */
23+ $ manager = $ this ->app ->make ($ manager_abstract = LivewireManager::class);
24+
25+ $ manager_mock = m::mock ($ manager )
26+ ->makePartial ()
27+ ->expects ('flushState ' )
28+ ->withNoArgs ()
29+ ->getMock ();
30+
31+ $ this ->app ->instance ($ manager_abstract , $ manager_mock );
32+
33+ /** @var m\MockInterface|WithApplication $event_mock */
34+ $ event_mock = m::mock (WithApplication::class)
35+ ->makePartial ()
36+ ->expects ('application ' )
37+ ->andReturn ($ this ->app )
38+ ->getMock ();
39+
40+ $ this ->listenerFactory ()->handle ($ event_mock );
41+ }
42+
43+ /**
44+ * @return ResetLivewireListener
45+ */
46+ protected function listenerFactory (): ResetLivewireListener
47+ {
48+ return new ResetLivewireListener ();
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments