- Posts: 32
- Thank you received: 3
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
beforeControllerAction event not called for custom controller
- jackrabbithanna
-
Topic Author
- Offline
- Junior Member
-
Less
More
2 years 3 months ago #209592
by jackrabbithanna
I've got a custom route and controller
Route definied in routes.php
$route+>/<_sid:\d+>/*'] = "custompath/version/<action>/sid/<_sid>";
Then I got a LS plugin, and subscribe to the beforeControllerAction event.
I know this works because I can get some diag output for surveys or admin pages
The controller provides HTML output, so I know that works.
class VersionController extends LSYii_Controller {
But for some reason, the plugin event subscriber never fires when I load the page for this controller.
Any ideas what I could be doing wrong?
Most recent stable version of LS 3.x
Thanks in advance!
Route definied in routes.php
$route+>/<_sid:\d+>/*'] = "custompath/version/<action>/sid/<_sid>";
Then I got a LS plugin, and subscribe to the beforeControllerAction event.
I know this works because I can get some diag output for surveys or admin pages
The controller provides HTML output, so I know that works.
class VersionController extends LSYii_Controller {
But for some reason, the plugin event subscriber never fires when I load the page for this controller.
Any ideas what I could be doing wrong?
Most recent stable version of LS 3.x
Thanks in advance!
The topic has been locked.
- DenisChenu
-
- Away
- LimeSurvey Community Team
-
Less
More
- Posts: 12895
- Thank you received: 2371
2 years 3 months ago #209594
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic beforeControllerAction event not called for custom controller
No real idea …
Maybe start without rewrite ?
Can you set your param to GET for testing purpose ?
Without real route : you want something like this
index.php?r=myowncontroller/myfunction&sid=123 for example ?
I don't know exactly but seems your APP didn't extend LSYii_Application
github.com/LimeSurvey/LimeSurvey/blob/bd...Application.php#L332
Maybe start without rewrite ?
Can you set your param to GET for testing purpose ?
Without real route : you want something like this
index.php?r=myowncontroller/myfunction&sid=123 for example ?
I don't know exactly but seems your APP didn't extend LSYii_Application
github.com/LimeSurvey/LimeSurvey/blob/bd...Application.php#L332
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- jackrabbithanna
-
Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 32
- Thank you received: 3
2 years 3 months ago #209628
by jackrabbithanna
Replied by jackrabbithanna on topic beforeControllerAction event not called for custom controller
I appreciate your time on this. Forgive my ignorance.
I was thinking that adding a controller would automatically integrate similar to what is in Core.
Is there an example of adding a "real route" ?
If not using routes.php, as I documented, then where can I define them?
That may help me understand the difference and what I am doing wrong.
This Limesurvey installation is tightly integrated to a Drupal system, which also has CiviCRM
The purpose of this route is to display a saved version of somebody's responses to a survey, sort of a printable version, but draws in information from the user's Drupal user session and CiviCRM contact information. For every page load of a survey, or one of several custom routes, I need to check to make sure the user has a valid Drupal user session, and if valid, add data drawn from these systems into the $_SESSION
This was accomplished by hacking LSYii_Controller.php previously, trying to move this custom to a plugin. This way for both the standard survey form, and custom controllers could do this same thing.
I was thinking that adding a controller would automatically integrate similar to what is in Core.
Is there an example of adding a "real route" ?
If not using routes.php, as I documented, then where can I define them?
That may help me understand the difference and what I am doing wrong.
This Limesurvey installation is tightly integrated to a Drupal system, which also has CiviCRM
The purpose of this route is to display a saved version of somebody's responses to a survey, sort of a printable version, but draws in information from the user's Drupal user session and CiviCRM contact information. For every page load of a survey, or one of several custom routes, I need to check to make sure the user has a valid Drupal user session, and if valid, add data drawn from these systems into the $_SESSION
This was accomplished by hacking LSYii_Controller.php previously, trying to move this custom to a plugin. This way for both the standard survey form, and custom controllers could do this same thing.
The topic has been locked.
- DenisChenu
-
- Away
- LimeSurvey Community Team
-
Less
More
- Posts: 12895
- Thank you received: 2371
2 years 3 months ago #209637
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic beforeControllerAction event not called for custom controller
I don't have idea on the good way to add a controller …
last time i need to do : i add a controller in application/controller directory …
I need to update then"welcome/survey list" page before twig.
I add HomeController.php
and in config 'defaultController' => 'home'
But after with route : it's just when url rewriting is activated.
Then : depend on the way you add the controller.
You must check www.yiiframework.com/doc/api/1.1
It's out of LimeSurvey here. (in my opinion)
last time i need to do : i add a controller in application/controller directory …
I need to update then"welcome/survey list" page before twig.
I add HomeController.php
Code:
class HomeController extends LSYii_Controller { }
and in config 'defaultController' => 'home'
But after with route : it's just when url rewriting is activated.
Then : depend on the way you add the controller.
You must check www.yiiframework.com/doc/api/1.1
It's out of LimeSurvey here. (in my opinion)
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- jackrabbithanna
-
Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 32
- Thank you received: 3
2 years 3 months ago #209640
by jackrabbithanna
Replied by jackrabbithanna on topic beforeControllerAction event not called for custom controller
Somehow the admin controller does work though. Going to admin paths invoke the beforeControllerAction event .. It uses separate controllers from what I can see.
class AdminController extends LSYii_Controller
"/admin" paths are configured in routes.php as well
I feel like one piece away from putting the puzzle together.
class AdminController extends LSYii_Controller
"/admin" paths are configured in routes.php as well
I feel like one piece away from putting the puzzle together.
The topic has been locked.
- DenisChenu
-
- Away
- LimeSurvey Community Team
-
Less
More
- Posts: 12895
- Thank you received: 2371
2 years 3 months ago #209641
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic beforeControllerAction event not called for custom controller
No, in actionClass
github.com/LimeSurvey/LimeSurvey/blob/b4...nController.php#L315
www.yiiframework.com/doc/api/1.1/CUrlManager
I really think (but maybe i'm false) «routes» are only used with urlRewriting.
github.com/LimeSurvey/LimeSurvey/blob/b4...nController.php#L315
www.yiiframework.com/doc/api/1.1/CUrlManager
I really think (but maybe i'm false) «routes» are only used with urlRewriting.
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.