My lack of D8 experience is going to show by just how many unknowns I have here. I hope someone can link some of the pieces for me.

I created a custom action using hook_entity_operation_alter() on the admin/structure/webform/manage/dis_document_generator/results/submissions page as you can see below. I'm guessing this will show up on various other pages to which is fine.

Currently as you can see the url is set to the current page but this needs to change once I have a controller redirect to. Also, it would be nice to add this operation through a controller instead of a hook but that's not important at the moment.

     * Implements hook_entity_operation_alter()
    function dis_doc_gen_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {
      if ($entity->getEntityTypeId() === 'webform_submission' && $entity->bundle() === 'dis_document_generator') {

        static $operation;
        static $permission;

        if (is_null($operation)) {
          $user = \Drupal::currentUser();
          $permission = $user->hasPermission('utilize mq client');

          $url = \Drupal\Core\Url::fromRoute('<current>');

          $operation = [
            'title' => t('Send XML'),
            'weight' => 8,
            'url' => $url,

        if ($permission) {
          $operations['send_xml'] = $operation;

I was using WebformSubmissionNotesForm.php as a sample to create a controller because it looked relatively simple but I'm not sure if it's a best choice because I don't actually need a form. I'm just going to perform an action and then return however using it for now.

The router for it is this:

  path: '/admin/structure/webform/manage/{webform}/submission/{webform_submission}/notes'
    _entity_form: 'webform_submission.notes'
    _title_callback: '\Drupal\webform\Controller\WebformSubmissionViewController::title'
    _entity_access: 'webform_submission.notes'

With my module being called dis_doc_gen I gather that my router details should look like this?:

  path: '/admin/structure/webform/manage/{webform}/submission/{webform_submission}/sendxml'
    _entity_form: 'dis_doc_gen.sendxml'
    _title_callback: 'Send XML'
    _entity_access: 'dis_doc_gen.utilize_mq_client'

where my permission is called utilize mq client and so I believe it would be represented here as dis_doc_gen.utilize_mq_client.

Finally, WebformSubmissionNotesForm.php sits under webform/src. The one plugin I managed to do for my webform had to go under webform/src/Plugin/WebformHandler so I'm wondering since this is off a webform submission whether I need to place a controller at:

  • webform/src or
  • webform/src/Plugin/WebformHandler or
  • webform/src/Plugin/WebformSubmissionHandler.

Last, webform defines WebformSubmissionNotesForm in it's header like this:

 * Defines the WebformSubmission entity.
 * @ingroup webform
 * @ContentEntityType(
 *   handlers = {
 *     "form" = {
 *       "notes" = "Drupal\webform\WebformSubmissionNotesForm",

Since I can't have that hardcoded like that for my new controller I gather that's fine because I can just attach my controller through the interface.


It seems the answer came from spending a day (and a bit) just studying the inner workings of D8 and realizing just how much is done for you that wasn't the case in D7.

Ultimately I want to send the action to a Controller, not a plugin and the primary source for getting enough grounding to figure it out came from the following:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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