symfony3 - Flarum forum developed based on laravel, what is the use of the GroupWillBeSaved event in the source code?
PHP中文网
PHP中文网 2017-05-16 16:52:29
0
1
701

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?

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
PHPzhong

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.

Where is the listener corresponding to the GroupWillBeSaved event?

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template