Skip to content

Commit

Permalink
revert listeners on evnets
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jul 11, 2017
1 parent 34f0afd commit 5ed4f50
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
25 changes: 0 additions & 25 deletions src/Illuminate/Foundation/Console/EventGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,13 @@ class EventGenerateCommand extends Command
*/
public function handle()
{
$this->makeDynamicListeners(
$provider = $this->laravel->getProvider(EventServiceProvider::class)
);

foreach ($provider->listens() as $event => $listeners) {
$this->makeEventAndListeners($event, $listeners);
}

$this->info('Events and listeners generated successfully!');
}

/**
* Generate the dynamic listeners which have "listensFor" properties.
*
* @param object $provider
* @return void
*/
protected function makeDynamicListeners($provider)
{
foreach ($provider->listeners() as $listener) {
if (! class_exists($listener)) {
$this->makeListeners(null, [$listener]);

continue;
}

foreach ($listener::$listensFor as $event) {
$this->makeEventAndListeners($event, [$listener]);
}
}
}

/**
* Make the event and listeners for the given event.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ class EventServiceProvider extends ServiceProvider
*/
protected $listen = [];

/**
* The event listeners for the application.
*
* @var array
*/
protected $listeners = [];

/**
* The subscriber classes to register.
*
Expand Down Expand Up @@ -61,24 +54,6 @@ public function register()
*/
public function listens()
{
return array_merge_recursive(collect($this->listeners)->filter(function ($listener) {
return class_exists($listener, false);
})->flatMap(function ($listener) {
return collect($listener::$listensFor)->map(function ($event) use ($listener) {
return ['event' => $event, 'listeners' => [$listener]];
})->all();
})->groupBy('event')->map(function ($listeners) {
return $listeners->pluck('listeners')->flatten(1)->all();
})->all(), $this->listen);
}

/**
* Get all of the registered listeners.
*
* @return array
*/
public function listeners()
{
return $this->listeners;
return $this->listen;
}
}

1 comment on commit 5ed4f50

@GitHub30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taylorotwell Why did you revert?

Please sign in to comment.