User tests: Successful: Unsuccessful:
To help resolve issue on PR #12505.
In order to add a new JModelAdmin
functionality which work similar to plugin event onContentBeforeDelete
and onContentAfterDelete
but can not be disabled by administrator.
Developer will have an option to write additional required events without override whole JModelAdmin->delete
method.
Code review.
JModelAdmin introduced a new methods that wrap plugin event call.
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Libraries |
But you can write:
function triggerBeforeDelete(...)
{
if (parent::triggerBeforeDelete($dispatcher, $context, $table) !== false)
{
// After plugin events success delete featured item before delete article row
}
}
Delete Featured items should be call after 'onContentBeforeDelete' success.
Similar to JLanguageAssociations from https://github.com/joomla/joomla-cms/pull/12670/files#diff-39b4bc5cb02bbace2ee4febe8f54583eL777
Take a look at PR #12505. I thought that this idea can be a better way.
Also I thought about add some new method to JTable
class but
adding method onBeforeDelete
will duplicate JObserver functionality.
I get that, this just doesn't feel right for adding hooks to the system though. Because at this point it's actually not a hook, it's just an extended method call but instead of extending the entire delete method you're just extending the triggers for the event dispatcher, and doesn't feel any better than #12505 to me.
OK thanks, then I close this PR.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-11-01 00:26:47 |
Closed_By | ⇒ | csthomas |
You shouldn't need to do this, because in theory if someone overrides these methods and doesn't call the parent then the delete events aren't dispatched either.
You can though add callbacks to the event dispatcher without them being a plugin event through
JEventDispatcher::getInstance()->register($eventName, $callable);
. So all you'd really need is to load these callbacks into the dispatcher before the event is triggered (I can't say I have a "clean" solution for that honestly).