How is onContentAfterSave working in the Front End?

by Irata   Last Updated September 05, 2019 23:10 PM - source

I have created a plugin that works using onContentAfterSave to fire off some other processing once a record is saved. This works as expected in the Back End but nothing gets triggered when I save a record in the front end.

The record I am saving is part of a custom component code, original coming from component creator some time ago if that may have something to do with it.

I can trap my plugin being triggered by core extensions like com_content when saving an article, the $context being com_content.form so I confirmed onContentAfterSave is available in the front end.

Looking through the site code I can see various components have triggers for onContentAfterSave or event_after_save which seems to be a new method but both comeback to this piece of code in AdminModel.php

if (isset($config['event_after_save']))
            {
                $this->event_after_save = $config['event_after_save'];
            }
            elseif (empty($this->event_after_save))
            {
                $this->event_after_save = 'onContentAfterSave';
            }

However I can't find any triggers being set in Front End libraries nor can I find other reference to code similar to above in frontend classes so I am assuming that someone how AdminModel.php is getting used by the FrontEnd at some stage or there is different approach for triggering being used in the frontEnd.

Following com_content I end up in class Table, ../libraries/src/Table/Table.php which has a couple of functions dealing with Observers that I think might be related but not sure and then this line in the store function

$this->_observers->update('onAfterStore', array(&$result));

All a bit lost now trying to understand if it is a new or different way and with J4 coming along what is the best approach to handle this for the future.

I could simply put a trigger somewhere in my code and move on, but I have been looking at this problem hours, getting near a day, trying to work out how it is working for com_content but not for my component.

Any pointers or explanations appreciated.

Terry



Related Questions


Develop a System Plugin with Sample Data for Options

Updated January 06, 2019 18:10 PM

How to remove rel="nofollow" with Joomla Buffer?

Updated May 28, 2017 04:10 AM