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.0] New onAfterInitialiseDocument event #40512

Merged
merged 8 commits into from
Jul 21, 2023

Conversation

Fedik
Copy link
Member

@Fedik Fedik commented Apr 30, 2023

Summary of Changes

The event that everyone waiting for :)
This should finally solve an issue everyone hit when need to access to Document at early stage, but onAfterRoute document not available and onAfterDispatch is to late.

PR also add a general Document event class, it introduce classes for 2 events: AfterInitialiseDocumentEvent, BeforeCompileHeadEvent

Note
Before we can merge this PR it would be good to add CMS\ApplicationEvent, and the document event should be a child of it (because technically it is Application event).
Thoughts?

Testing Instructions

Apply #40522 then apply current patch. Solve conflicts.
Add in any System plugin:

public function onAfterInitialiseDocument(Joomla\CMS\Event\Application\AfterInitialiseDocumentEvent $event)
{
    var_dump($event->getDocument()->getTitle());
}

Actual result BEFORE applying this Pull Request

Nothing

Expected result AFTER applying this Pull Request

You should see Dump output.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org: https://docs.joomla.org/Plugin/Events#System
  • No documentation changes for docs.joomla.org needed
  • Pull Request link for manual.joomla.org: IDK
  • No documentation changes for manual.joomla.org needed

@Fedik Fedik marked this pull request as draft April 30, 2023 10:27
@dgrammatiko
Copy link
Contributor

Merge it!

@Fedik Fedik marked this pull request as ready for review April 30, 2023 12:51
@Fedik
Copy link
Member Author

Fedik commented Apr 30, 2023

Note: I have removed Event classes from this PR, it is better to do separately, with all Application events.

@HLeithner
Copy link
Member

Note: I have removed Event classes from this PR, it is better to do separately, with all Application events.

Nope, all new events must have a corresponding class, also you don't provide the $document in the event now.

please revert your cleanup again.

@Fedik
Copy link
Member Author

Fedik commented Apr 30, 2023

all new events must have a corresponding class

I fully agree, but unfortunately here we have to wait when Application event classes will be implemented.
Doing it here will be like runing on front of a train.

I mean that PR should go first. Then classes can be added in this one.
I maybe try to preapre something later.

@Fedik
Copy link
Member Author

Fedik commented May 7, 2023

I have re-added the event class, now it will work with #40522,
However, merge conflicts is expected :)

 Conflicts:
	libraries/src/Application/ApiApplication.php
@HLeithner HLeithner merged commit 2d3f8da into joomla:5.0-dev Jul 21, 2023
@HLeithner
Copy link
Member

thanks

@HLeithner HLeithner added this to the Joomla! 5.0 milestone Jul 21, 2023
@HLeithner
Copy link
Member

maybe we get a manual.joomla.org entry please?

@Fedik Fedik mentioned this pull request Jul 21, 2023
4 tasks
@Fedik Fedik deleted the document-event branch July 21, 2023 12:10
@Fedik
Copy link
Member Author

Fedik commented Jul 21, 2023

I will make it.
Also will be need update https://docs.joomla.org/Plugin/Events#System

GeraintEdwards pushed a commit to GeraintEdwards/joomla-cms that referenced this pull request Aug 14, 2023
* Document event: BeforeCompileHeadEvent

* Document event: AfterInitialiseDocumentEvent

* Document event, phpcs

* Document event, revert classes

* Document event, cleanup

* Document event, AfterInitialiseDocument Event
GeraintEdwards pushed a commit to GeraintEdwards/joomla-cms that referenced this pull request Aug 14, 2023
* Document event: BeforeCompileHeadEvent

* Document event: AfterInitialiseDocumentEvent

* Document event, phpcs

* Document event, revert classes

* Document event, cleanup

* Document event, AfterInitialiseDocument Event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants