You are here

contact_storage_export.module in Contact Storage Export 8

File

contact_storage_export.module
View source
<?php

/**
 * @file
 * Contains contact_storage_export.module..
 */
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
use Drupal\contact_storage_export\ContactStorageExportBatches;

/**
 * Implements hook_help().
 */
function contact_storage_export_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {

    // Main module help for the contact_storage_export module.
    case 'help.page.contact_storage_export':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Provides a way to export Contact Form submissions to CSV.') . '</p>';
      return $output;
    default:
  }
}

/**
 * Implements hook_entity_operation_alter().
 */
function contact_storage_export_entity_operation_alter(array &$operations, EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() == 'contact_form') {
    if (\Drupal::service('router.route_provider')
      ->getRouteByName("entity.contact_form.export_form")) {
      $operations['export_form'] = [
        'title' => t('Export submissions'),
        'url' => Url::fromRoute("entity.contact_form.export_form", [
          $entity
            ->getEntityTypeId() => $entity
            ->id(),
        ]),
        'weight' => 50,
      ];
    }
  }
}

/**
 * Process callback for the batch created in the export form.
 */
function _contact_storage_export_process_batch($settings, &$context) {
  ContactStorageExportBatches::processBatch($settings, $context);
}

/**
 * Finish callback for the batch created in the export form.
 */
function _contact_storage_export_finish_batch($success, $results, $operations) {
  return ContactStorageExportBatches::finishBatch($success, $results, $operations);
}

Functions

Namesort descending Description
contact_storage_export_entity_operation_alter Implements hook_entity_operation_alter().
contact_storage_export_help Implements hook_help().
_contact_storage_export_finish_batch Finish callback for the batch created in the export form.
_contact_storage_export_process_batch Process callback for the batch created in the export form.