Skip to content

Add CLI option to register subscribers - #2

Draft
Jean85 wants to merge 226 commits into
theseer:eventfrom
Jean85:add-subscribers-cli-option
Draft

Add CLI option to register subscribers#2
Jean85 wants to merge 226 commits into
theseer:eventfrom
Jean85:add-subscribers-cli-option

Conversation

@Jean85

@Jean85 Jean85 commented Mar 11, 2020

Copy link
Copy Markdown

This is WIP, do not merge.

I was looking into #1 and I would personally like and need a way to add subscribers through CLI options. So I drafted this PR using sebastianbergmann#4136 as a base. While doing this I noticed two different things:

  • there's no way yet to reach the Dispatcher singleton to register new subscribers in any way
  • registering the subscribers in the way that I'm trying to is pretty limited, since it's in the TestRunner: it could happen too late for a number of events that are fired before

So... How do you want to proceed? What steps can I take?

[EDIT] /cc @sebastianbergmann, this is my initial feedback on this implementation

Comment thread src/TextUI/TestRunner.php
}

foreach ($arguments['subscribers'] as $subscriber) {
// TODO - how to register new subscribers?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This will be done via our Events\Facade.

Right now, you could query the Facade for the Dispatcher (Events\Facade::dispatcher()) and call register() to add subscribers.

This is work in progress and the Facade will soon provide a direct API without leaking the Dispatcher.

@theseer

theseer commented Mar 11, 2020

Copy link
Copy Markdown
Owner

Thanks for the work already.

While I'm not yet sure what your goal is, I'm not convinced this is going the right way: A Subscriber is code that needs to be loaded and run. A Subscriber by itself is just a receiver of events. Why would you need a CLI option for that?

We need a technical API to have "things" register subscribers but that step is a prerequisite to actually do something with the event and I don't see how this would be a CLI option?

@localheinz
localheinz force-pushed the event branch 3 times, most recently from 880566d to d1c7d35 Compare October 16, 2020 14:02
@localheinz
localheinz force-pushed the event branch 5 times, most recently from 29c6d6c to cb8c558 Compare October 30, 2020 11:58
@localheinz
localheinz force-pushed the event branch 7 times, most recently from 41b2928 to 0af80ac Compare November 6, 2020 11:43
@localheinz
localheinz force-pushed the event branch 14 times, most recently from 111ee05 to 03bd5c4 Compare November 13, 2020 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants