0

Is it possible to create an action in Drupal 8 and point it at a deriver class to generate them automatically?

For example with Custom Publishing Options I have a ConfigurableActionBase action that lets a user create an advanced action, select the publishing option and the value, and save the action.

Ideally, I would like to have a generic action derived from all existing publishing options so that admins don't have to create the action manually every time they add a new custom publishing option. Along with that, if they deleted the entity, I would want the action to be removed as well.

I was able to create a class extended DeriverBase and define plugin derivatives, but was having issues getting it to pick up in my class extending ActionBase with deriver set in the annotation. My example code is on my home laptop, will post it when I have a chance.

2
  • I have used only few derivatives but from what I understand any plugin can implement deriver class.
    – user21641
    Feb 22, 2016 at 23:37
  • Yes, it appears my derivatives are registered (breakpoints are triggered within the class) but what I expect to happen does not happen, instances of the Action plugin do not appear on the list of Actions in the admin.
    – Kevin
    Feb 23, 2016 at 14:14

1 Answer 1

0

You've probably figured this out by now as this was asked in 2016, but you can indeed use a plug-in deriver to create actions. The part that trips people up (including myself) is that you also need to create an action config for Drupal to even list the action, as mentioned in this answer by mpp. I think there's some additional trickery that might be required to make it work with derivatives that I haven't figured out entirely yet.

Not the answer you're looking for? Browse other questions tagged or ask your own question.