wse-1.0.x-dev/modules/wse_task_monitor/wse_task_monitor.module

modules/wse_task_monitor/wse_task_monitor.module
<?php

/**
 * @file
 * Task monitoring functionality for workspace operations.
 */

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Hook\Attribute\LegacyHook;
use Drupal\wse_task_monitor\Hook\WorkspacePublishingTaskMonitor;

/**
 * Implements hook_entity_update() as a legacy fallback.
 */
#[LegacyHook]
function wse_task_monitor_entity_update(EntityInterface $entity): void {
  $hook_service = \Drupal::service(WorkspacePublishingTaskMonitor::class);
  $hook_service->entityUpdate($entity);
}

/**
 * Implements hook_form_alter().
 */
function wse_task_monitor_form_alter(&$form, FormStateInterface $form_state, $form_id): void {
  // Forms that create workspace tasks and need monitoring.
  $task_creating_forms = [
    'workspace_publish_form',
    'workspace_revert_form',
    'entity_workflow_simple_transition_form',
    'entity_workflow_form',
  ];

  if (in_array($form_id, $task_creating_forms)) {
    // Attach task monitor library.
    $form['#attached']['library'][] = 'wse_task_monitor/task-monitor';
    $form['#attributes']['data-wse-task-monitor'] = 'true';
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc