Flarum forum developed based on laravel, what is the use of the GroupWillBeSaved
event in the source code?
$this->events->fire(
new GroupWillBeSaved($group, $actor, $data)
);
https://github.com/flarum/core/blob/master/src/Core/Command/EditGroupHandler.php
1) Event and listener are used in pairs. GroupWillBeSaved
Where is the listener corresponding to the event?
2)events->fire(new GroupWillBeSaved($group, $actor, $data));
What is the execution process?
Someone actually asked a question about Flarum in segmentfault.
I am the maintainer of Flarum Chinese Community. My current main work is Chinese language package and document localization. I also read a little bit of Flarum source code.
We are glad that you are interested in Flarum, and you are welcome to join the Flarum Chinese community and contribute.
This is a typical Pub/Sub mode, which is used to decouple the system and provide flexible scalability.
For the first question, you can search for "GroupWillBeSaved", https://github.com/flarum/core/search?utf8=%E2%9C%93&q=GroupWillBeSaved
3 results found. One is definition
GroupWillBeSaved
,另外两个是触发GroupWillBeSaved
.GroupWillBeSaved event has no corresponding Listener at all.
Then why is it designed like this?
Because the goal of Flarum is to develop a microkernel, other functions can be implemented through extensions. When we extend the Flarum kernel, we need to listen to different events. In the same way, Flarum will fire various events during operation. Although the Flarum core does not handle all of these events, when we develop extensions, we can handle the events that interest us.
Most systems will mount various hooks during execution, and Flarum's Pub/Sub mode is obviously more conducive to expansion.