Skip to content

Commit 785dbb9

Browse files
authored
Merge pull request #1 from JeremyDunn/main
Dispatch on NavTreeSaved and when form blueprint is saved
2 parents 6b7484a + 1a4a481 commit 785dbb9

9 files changed

+27
-43
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace DoeAnderson\StatamicGithubWorkflowDispatch\Listeners;
4+
5+
use DoeAnderson\StatamicGithubWorkflowDispatch\Jobs\DispatchGithubWorkflowJob;
6+
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Statamic\Events\BlueprintSaved;
8+
9+
class BlueprintSavedListener implements ShouldQueue
10+
{
11+
public function handle(BlueprintSaved $event): void
12+
{
13+
if ($event->blueprint->namespace() === 'forms' && config('statamic-github-workflow-dispatch.event-types.form')) {
14+
DispatchGithubWorkflowJob::dispatch();
15+
}
16+
}
17+
}

src/Listeners/CollectionSavedListener.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88

99
class CollectionSavedListener implements ShouldQueue
1010
{
11-
/**
12-
* Handle the event.
13-
*
14-
* @param CollectionSaved $event
15-
* @return void
16-
*/
1711
public function handle(CollectionSaved $event)
1812
{
1913
if (config('statamic-github-workflow-dispatch.event-types.collection')) {

src/Listeners/EntryListener.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88

99
class EntryListener implements ShouldQueue
1010
{
11-
/**
12-
* Handle the event.
13-
*
14-
* @param \Statamic\Events\EntrySaved|\Statamic\Events\EntryDeleted $event
15-
* @return void
16-
*/
1711
public function handle(Event $event): void
1812
{
1913
if (config('statamic-github-workflow-dispatch.event-types.entry')) {

src/Listeners/FormListener.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88

99
class FormListener implements ShouldQueue
1010
{
11-
/**
12-
* Handle the event.
13-
*
14-
* @param \Statamic\Events\FormSaved|\Statamic\Events\FormDeleted $event
15-
* @return void
16-
*/
1711
public function handle(Event $event): void
1812
{
1913
if (config('statamic-github-workflow-dispatch.event-types.form')) {

src/Listeners/GlobalSetSavedListener.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88

99
class GlobalSetSavedListener implements ShouldQueue
1010
{
11-
/**
12-
* Handle the event.
13-
*
14-
* @param \Statamic\Events\GlobalSetSaved $event
15-
* @return void
16-
*/
1711
public function handle(GlobalSetSaved $event): void
1812
{
1913
if (config('statamic-github-workflow-dispatch.event-types.global-set')) {

src/Listeners/NavSavedListener.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44

55
use Illuminate\Contracts\Queue\ShouldQueue;
66
use DoeAnderson\StatamicGithubWorkflowDispatch\Jobs\DispatchGithubWorkflowJob;
7+
use Statamic\Events\Event;
78
use Statamic\Events\NavSaved;
89

910
class NavSavedListener implements ShouldQueue
1011
{
11-
/**
12-
* Handle the event.
13-
*
14-
* @param \Statamic\Events\NavSaved $event
15-
* @return void
16-
*/
17-
public function handle(NavSaved $event): void
12+
public function handle(Event $event): void
1813
{
1914
if (config('statamic-github-workflow-dispatch.event-types.nav')) {
2015
DispatchGithubWorkflowJob::dispatch();

src/Listeners/TaxonomySavedListener.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88

99
class TaxonomySavedListener implements ShouldQueue
1010
{
11-
/**
12-
* Handle the event.
13-
*
14-
* @param TaxonomySaved $event
15-
* @return void
16-
*/
1711
public function handle(TaxonomySaved $event): void
1812
{
1913
if (config('statamic-github-workflow-dispatch.event-types.taxonomy')) {

src/Listeners/TermListener.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88

99
class TermListener implements ShouldQueue
1010
{
11-
/**
12-
* Handle the event.
13-
*
14-
* @param \Statamic\Events\TermSaved|\Statamic\Events\TermDeleted $event
15-
* @return void
16-
*/
1711
public function handle(Event $event): void
1812
{
1913
if (config('statamic-github-workflow-dispatch.event-types.term')) {

src/ServiceProvider.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
namespace DoeAnderson\StatamicGithubWorkflowDispatch;
44

5+
use Statamic\Events\BlueprintSaved;
6+
use Statamic\Events\NavTreeSaved;
57
use Statamic\Facades\Utility;
68
use Statamic\Providers\AddonServiceProvider;
79
use DoeAnderson\StatamicGithubWorkflowDispatch\Http\Controllers\CP\GithubWorkflowDispatchUtilityController;
810

911
class ServiceProvider extends AddonServiceProvider
1012
{
1113
protected $listen = [
14+
\Statamic\Events\BlueprintSaved::class => [
15+
\DoeAnderson\StatamicGithubWorkflowDispatch\Listeners\BlueprintSavedListener::class,
16+
],
1217
\Statamic\Events\CollectionSaved::class => [
1318
\DoeAnderson\StatamicGithubWorkflowDispatch\Listeners\CollectionSavedListener::class,
1419
],
@@ -30,6 +35,9 @@ class ServiceProvider extends AddonServiceProvider
3035
\Statamic\Events\NavSaved::class => [
3136
\DoeAnderson\StatamicGithubWorkflowDispatch\Listeners\NavSavedListener::class,
3237
],
38+
\Statamic\Events\NavTreeSaved::class => [
39+
\DoeAnderson\StatamicGithubWorkflowDispatch\Listeners\NavSavedListener::class,
40+
],
3341
\Statamic\Events\TaxonomySaved::class => [
3442
\DoeAnderson\StatamicGithubWorkflowDispatch\Listeners\TaxonomySavedListener::class,
3543
],

0 commit comments

Comments
 (0)