I have a custom plugin that implement a context reaction like this:

namespace Drupal\mymodule\Plugin\ContextReaction;

 * Provides a context reaction.
 * @ContextReaction(
 *   id = "banner",
 *   label = @Translation("Banner image")
 * )
class MyReaction extends ContextReactionPluginBase implements ContainerFactoryPluginInterface {...}

The plugin configuration form has a managed file field, and I add the file usage on submission.

When a plugin instance is deleted, I must remove that file usage. How can I do it?

  • 1
    I don't know what a ContextReaction (rules?) plugin is, but it would have to provide an API that is called when something is removed, otherwise you need to listen on whatever configuration entity is being deleted in hook_entity_delete()
    – Berdir
    Feb 7, 2017 at 17:21
  • @Berdir, thanks you for your comment, it seems that subscribing to entity operations is the right way. FYI it's a plugin for drupal.org/project/context module. It extends Drupal\Core\Plugin\PluginBase. I though there might be a general approach to react on plugins instances CRUD operations I have not managed to find. Feb 7, 2017 at 22:56


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.