Skip to content

Conversation

@ADmad
Copy link
Member

@ADmad ADmad commented Nov 18, 2023

@ADmad ADmad added this to the 5.next milestone Nov 18, 2023
---------------------

// Somewhere before calling one of the HTTP client's send methods.
\Cake\Event\EventManager::instance()->on(
Copy link
Contributor

@LordSimal LordSimal Nov 18, 2023

Choose a reason for hiding this comment

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

Aren't events only dispatched on the client object and not on the global event manager?
I just learned instance level events will also appear in the global event manager.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm.. This makes me think that suggesting $client->getEventManager()->on() would be better.

@ADmad ADmad force-pushed the http-client-events branch from fff1aa5 to f701891 Compare November 18, 2023 14:35
---------------------

// Somewhere before calling one of the HTTP client's methods which makes a request
$http->getEventManager()->on(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$http->getEventManager()->on(
$client->getEventManager()->on(

Copy link
Member Author

Choose a reason for hiding this comment

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

All code examples above use the var $http for the client instance, hence I used the same for consistency.

Copy link
Member

Choose a reason for hiding this comment

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

The example on 480 uses $client. I can take care of normalizing them all though.

---------------------

// Somewhere before calling one of the HTTP client's methods which makes a request
$http->getEventManager()->on(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$http->getEventManager()->on(
$client->getEventManager()->on(

@markstory markstory merged commit f2d052a into 5.next Nov 19, 2023
@markstory markstory deleted the http-client-events branch November 19, 2023 16:06
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.

4 participants