View Issue Details

IDProjectCategoryView StatusLast Update
14615Development [All Projects] Pluginspublic2019-04-03 09:40
ReporterbismarkAssigned Toc_schmitz 
PrioritynoneSeverityfeature 
Status assignedResolutionopen 
Product Version 
Target VersionFixed in Version 
Summary14615: new PluginEvent onBeginRequest
Description

it is possible to create this event by myself in application/config/config.php

'onBeginRequest' => function($event) {
$event = new PluginEvent('onBeginRequest');
Yii::app()->getPluginManager()->dispatchEvent($event);
},

I would like to have this event available by default in limesurvey to let plugins come into action as early as possible

TagsNo tags attached.

Activities

bismark

bismark

2019-03-08 01:29

reporter   ~50824

PluginEvent afterPluginLoad, which is imho earlier than onBeginRequest, doesnt work for me

Mazi

Mazi

2019-03-08 10:09

partner   ~50825

Denis, what's your opinion on this?

DenisChenu

DenisChenu

2019-03-08 10:18

developer   ~50826

beforeControllerAction is done after onBeginRequest ?

But : if afterPluginLoad is not happen : plugin is not loaded ? Maybe review it to be more sooner ?
Else : i use init directly when i need it the most sooner i can.
Else : about a beginRequest : test if we can add some CRSF disable (for example) can be great.
Think it can be interseting (the question : is it really a new feature (the 4.0) or is it OK in 3.X …)

PS : great tips about config to add event :)

DenisChenu

DenisChenu

2019-03-08 10:19

developer   ~50827

OK in 3.X if @bismark make the pull request ?

bismark

bismark

2019-03-08 10:40

reporter   ~50828

in my plugin I do something like this:

public function init()
{
$this->subscribe('onBeginRequest');
}

public function onBeginRequest()
{
    // this works on afterPluginLoad, too
    Yii::setPathOfAlias('consultinglib', dirname(__FILE__)); 

   // this not
    Yii:app()->setModules(array(
        'forum' => array(
            'class' => 'consultinglib.modules.forum.ForumModule',
        )
    ), true);
}

the idea is to use https://www.yiiframework.com/doc/guide/1.1/en/basics.module
with this plugin activated, you can call index.php/forum
also the plugin parameter system could be used to config the module

DenisChenu

DenisChenu

2019-03-08 11:36

developer   ~50834

Did Yii:app()->setModules can work in init ? Did you test ?

Else : still a good event to have something related to request :)

bismark

bismark

2019-03-08 12:03

reporter   ~50842

just tested setModules in init() of the Plugin <- doesnt work, 404 Could not resolve request

bismark

bismark

2019-03-08 15:03

reporter   ~50853

https://github.com/LimeSurvey/LimeSurvey/pull/1242

ollehar

ollehar

2019-04-02 14:48

administrator   ~51274

This sounds like something that should be handled by a component system instead (adding modules dynamically to Yii).

ollehar

ollehar

2019-04-02 14:49

administrator   ~51275

But if the event is accepted, it should probably add the $request variable to the event.

DenisChenu

DenisChenu

2019-04-02 19:29

developer   ~51288

Last edited: 2019-04-02 19:31

View 2 revisions

@ollehar : in beforeControllerAction i add run like the Yii event : https://www.yiiframework.com/doc/api/1.1/CWebApplication#beforeControllerAction-detail

But https://www.yiiframework.com/doc/api/1.1/CApplication#onBeginRequest-detail don't have any param/system? There are no request var at this time (except $_POST,$_GET …)

[edit]
Maybe we can look at event->sender and event->params to check if we have somthing interesting ?

Mazi

Mazi

2019-04-03 09:40

partner   ~51292

@c_schmitz, can we add those 3 lines of code for the plugin request required for LS 3? It is no new feature, just a plugin event and we had added half a dozen plugin events to the stable LS3 version in the past since it will do no harm.

For LS 4 we can use a different approach once we can properly include modules but for the current LS 3 version we need that event.

Issue History

Date Modified Username Field Change
2019-03-07 18:01 bismark New Issue
2019-03-08 01:29 bismark Note Added: 50824
2019-03-08 10:08 Mazi Assigned To => DenisChenu
2019-03-08 10:08 Mazi Status new => assigned
2019-03-08 10:09 Mazi Note Added: 50825
2019-03-08 10:18 DenisChenu Note Added: 50826
2019-03-08 10:19 DenisChenu Assigned To DenisChenu => c_schmitz
2019-03-08 10:19 DenisChenu Status assigned => feedback
2019-03-08 10:19 DenisChenu Note Added: 50827
2019-03-08 10:40 bismark Note Added: 50828
2019-03-08 10:40 bismark Status feedback => assigned
2019-03-08 11:36 DenisChenu Note Added: 50834
2019-03-08 12:03 bismark Note Added: 50842
2019-03-08 15:03 bismark Note Added: 50853
2019-04-02 14:48 ollehar Note Added: 51274
2019-04-02 14:49 ollehar Note Added: 51275
2019-04-02 19:29 DenisChenu Note Added: 51288
2019-04-02 19:31 DenisChenu Note Edited: 51288 View Revisions
2019-04-03 09:40 Mazi Note Added: 51292