Topics

Tribe Support

Tribe Support's Topics

Nick Swinford

Nick Swinford

November 08 2017

Component Events

I have a component called network that adds a dashboard with all publicly view-able stories and media. In the network template file, I change the filter to network and then look for that filter in the plugin where I override the query.

Loading ...

This was working fine until the upgrade. I've check and double checked everything and can't seem to see why it's not working. Could this be because of some of the controller changes?

You can view the instructions here: https://github.com/anahitasocial/anahita/blob/master/src/plugins/anahita/default.php

Nick Swinford
Nick Swinford
November 14 2017 Permalink
@Rastin, did you see this? I was wondering if this is broken or removed.
Rastin Mehr
Rastin Mehr
November 14 2017 Permalink
Could you try a different approach instead? Write a controller behaviour and put your code in the _actionBrowse method in it. Then use the onBeforeDispatch event in system plugin to obtain the controllers that you want and add the behaviour to them. I'm not sure if the onAfterControllerBrowse events are available within the system plugin. I know onAfterControllerBrowse are used in the toolbar classes.
Rastin Mehr
Rastin Mehr
November 14 2017 Permalink
The onAfterControllerBrowse might work better than _actionBrowse in your custom network behaviour.
Nick Swinford
Nick Swinford
November 14 2017 Permalink
Just to be clear, this works in 4.2.x. It only stopped working after your controller shenanigans.

Yeah, I can try a different approach, but this approach is very close to your desire to allow components to listen to all controller events and react to them instead of having plugins.
Rastin Mehr
Rastin Mehr
November 15 2017 Permalink
A lot changed from 4.2 to 4.3. We removed Joomla remember. The approach I am recommending is also a prefered approach. We should be able to add behaviors to controllers or replace them using an alias in a system plugin. Same thing with entity classes.

It would be nice if we could get rid of user and authentication plugins and add behaviours to the person and session controllers via a system plugin. It would be a cleaner design in the end.
Nick Swinford
Nick Swinford
November 15 2017 Permalink
Sorry to throw more onto your plate, but something's gotta be wrong. I took your advice and attempted to insert the functionality as a behavior, but it had no effect.

Loading ...


So I attempted aliasing the controller with a customer one and that had no effect either.

Loading ...


Do you see anything wrong in my code?
Rastin Mehr liked this
Rastin Mehr
Rastin Mehr
November 16 2017 Permalink
I appreciate the fact that you tried, because I really want to make this work. Let me do some prototyping on my end and see what I can come up with.
Nick Swinford
Nick Swinford
November 17 2017 Permalink
I spent more time debugging this today and got no where. The only thing I think could be causing the issue is that the plugin event isn't firing earlier enough in the process to inject the behavior and let the behavior react.

I think this because I did $this->getBehaviors() in the stories controller _actionBrowse and got 7 behaviors with none of them being networkable.

Want me to throw my code into a github repo to make it easier for you to take a look?
Rastin Mehr liked this
Rastin Mehr
Rastin Mehr
November 17 2017 Permalink
That would be a good idea. Will you be alright to put it in a public repo? If it is private, you can add me to the repo. My username is: rmdstudio
Nick Swinford
Nick Swinford
January 01 2018 Permalink
Here's the repo (https://github.com/NicholasJohn16/network) for testing. All you should need to do is uncomment the different sections in the plugin's onAfterDispatch function (https://github.com/NicholasJohn16/network/blob/master/src/plugins/system/network.php) and test to see what happens. I left some comments about to help explain things.

Also, I noticed that my username override plugin (https://github.com/NicholasJohn16/plg-username) suddenly stopped working. I updated it to 4.3 two months ago and tested it. Everything was fine then, but when I upgraded to the latest Anahita, it's not working.
Rastin Mehr liked this
Rastin Mehr
Rastin Mehr
January 01 2018 Permalink
Thank you Nick! Happy New Year!
Rastin Mehr
Rastin Mehr
January 29 2018 Permalink
While Anahita React is moving forward smoothly I can look back on some php development too. I'll look into this issue next.
Nick Swinford liked this
Nick Swinford
Nick Swinford
January 30 2018 Permalink
Thanks Rastin. I appreciate it.
Rastin Mehr
Rastin Mehr
February 04 2018 Permalink
So I spend this afternoon to figure this out and unfortunately our code doesn't let us add behaviors to controllers from a system plugin. Here were the problems:

1. behaviour cannot be included in the plugin package, because we don't have an identifier to load it. It has to be included in a component.

2. I tried loading the behavior from a com_examples component and then add it to the people controller in example system plugin. It did execute the construct and init methods, but methods such as _beforeControllerBrowse or _afterControllerBrowse where not being called from the behavior.

I am kind of heart broken, because Kodekit https://github.com/timble/kodekit does this nicely. We can perhaps rewrite our controller, behaviour, plugin code from ground up and use some of their ideas. It's not something I want to work on until our React app has reached some major milestones.

Now the questions is, what other options do we have for you to overwrite an existing class. Any ideas?
@rastin, I've done some more digging on this issue and plugins in general. Plugins only seem to work on the / route, but after some testing I've figured out that on all other routes, they just aren't being imported properly. I'm still trying to figure out why that is, but I have a bit of a fix for the short term.

Is there a particular reason why you do this (https://github.com/anahitasocial/anahita/blob/master/src/libraries/anahita/functions.php#L639-L641)? What I'm thinking is happening is that a system plugin is firing before all the system plugins have a chance to load and because of that, none of the rest get imported. For some reason, the Anahita System plugin always fires, but no others will.

If you remove that check and just always allow the import, all the plugins fire as before and seem to work normally from the nominal testing I've done so far.
Rastin Mehr liked this
Rastin Mehr
Rastin Mehr
April 26 2018 Permalink
That's a good find. Would you please be able to start a new topic in the project group for this specific issue?

Powered by Anahita