I'm attempting to make something occur at a specific event in the GatherContent module found here https://www.drupal.org/project/gathercontent

Based on the information here http://help.gathercontent.com/importing-and-exporting-content/drupal-integration/drupal-integration-extending-the-module-using-the-api and several tutorials and documentation

I created a module with the code entered like so


    class: '\Drupal\my_gathercontent\EventSubscriber\MyGatherContentSubscriber'
      - { name: 'event_subscriber' }


namespace Drupal\my_gathercontent\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

 * Event Subscriber MyGatherContentSubscriber.

class MyGatherContentSubscriber implements EventSubscriberInterface {
    public function onGatherContentPostImport(DrupalgathercontentEventPostImportEvent $event) {
        \Drupal::logger('my_gathercontent')->notice('This is a test');
        drupal_set_message("Debug: This is a test.");
    public static function getSubscribedEvents() {
        $events['gathercontent.post_import'] = ['onGatherContentPostImport'];
        return $events;

And none of those messages get logged. I do now receive a page not found message after performing an action that should trigger that event. I'm not sure what I'm doing wrong.

Is there something wrong with the way I'm attempting to subscribe to the event?

1 Answer 1


Each event in the $events array should itself be an array; try:

$events['gathercontent.post_import'][] = ['onGatherContentPostImport'];

Your Answer

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

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