We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

EntrySaved event listener not working

Alex August 16, 2021 by Alex

Hi

I added a custom listener to the EntrySaved event which should just write a log entry, but somehow this listener on this event is not working... Below is my ServiceProvider and the created Listener

EventServiceProvider.php

namespace App\Providers;

use App\Listeners\TestListener;
use Illuminate\Support\Facades\Event;
use Statamic\Events\EntrySaved;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        EntrySaved::class => [
            TestListener::class,
        ],
    ];
}

TestListener.php

namespace App\Listeners;

use Illuminate\Support\Facades\Log;
use Statamic\Events\EntrySaved;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class TestListener
{
    /**
     * Handle the event.
     *
     * @param EntrySaved $event
     * @return void
     */
    public function handle(EntrySaved $event)
    {
        Log::info('Test listener fired');
    }
}

I added a log inside src/Events/EntrySaved.php and this log is written but the one inside the listener is not

Am I doing something wrong or am I missing something to create a listener on a Statamic event?

Thank you very much for your help

>>>>>>> Unanswered <<<<<<<
1 Reply
3 Followers