Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Auto-discovery of event listeners not working #9862

Closed
robdekort opened this issue Apr 11, 2024 · 1 comment
Closed

[5.x] Auto-discovery of event listeners not working #9862

robdekort opened this issue Apr 11, 2024 · 1 comment
Labels

Comments

@robdekort
Copy link
Contributor

Bug description

In Alpha 1 and 2 I'm using an Event Listener in app/Listeners/PreventDeletingMounts.php. This Listener prevents users from deleting pages that have a mounted collection on them.

namespace App\Listeners;

use Statamic\Events\EntryDeleting;
use Statamic\Facades\Collection;

class PreventDeletingMounts
{
    /**
     * Handle the event.
     */
    public function handle(EntryDeleting $event): void
    {
        if (Collection::findByMount($event->entry)) {
            throw new \Exception(trans('strings.collection_mounted', ['title' => $event->entry['title']]));
        }
    }
}

In Laravel 10 I had to register this in my EventServiceProvider but in Laravel 11 it's supposed to auto-discover those listeners.

It seems in my case this isn't happening. The listener isn't triggering, nor is it listed when running php artisan event:list.

How to reproduce

  1. Create a listener
  2. Don't manually register it
  3. Run php artisan event:list

Logs

No response

Environment

Environment
Application Name: Statamic Peak Development
Laravel Version: 11.3.1
PHP Version: 8.3.4
Composer Version: 2.7.1
Environment: local
Debug Mode: ENABLED
URL: statamic-peak.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: sqlite
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 4
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.0.0-alpha.2 PRO

Statamic Addons
studio1902/statamic-peak-browser-appearance: dev-feature/v5-support
studio1902/statamic-peak-commands: dev-feature/v5-support
studio1902/statamic-peak-seo: dev-feature/v5-support
studio1902/statamic-peak-tools: dev-feature/v5-support

Installation

Starter Kit using via CLI

Antlers Parser

None

Additional details

No response

@robdekort
Copy link
Contributor Author

Awesome, this works again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants