wsdl_docs-3.0.0-beta3/wsdl_docs.module

wsdl_docs.module
<?php

declare(strict_types = 1);

/**
 * @file
 * Calls general hooks for WSDL Docs module.
 */

use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\NodeInterface;

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function wsdl_docs_node_insert(NodeInterface $node): void{
  if ($node->getType() === 'soap_service') {
    \Drupal::service('wsdl_docs.soap_client_manager')->saveSoapNode($node);
  }
}

/**
 * Implements hook_ENTITY_TYPE_update().
 */
function wsdl_docs_node_update(NodeInterface $node): void{
  if ($node->getType() === 'soap_service') {
    \Drupal::service('wsdl_docs.soap_client_manager')->saveSoapNode($node);
  }
}

/**
 * Implements hook_entity_extra_field_info().
 */
function wsdl_docs_entity_extra_field_info(): array{
  $extra['node']['soap_service']['display'] = [
    'operations_list' => [
      'label' => t('WSDL Operations List'),
      'description' => t('A linked list of titles of the operations derived from this SOAP service.'),
      'weight' => 0,
    ],
  ];
  return $extra;
}

/**
 * Implements template_preprocess_TEMPLATE().
 */
function wsdl_docs_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode): void{
  if ($entity->getType() === 'soap_service') {
    $build['operations_list'] = [
      '#type' => 'fieldset',
      '#title' => t('Operations'),
      'content' => views_embed_view('wsdl_operations', 'soap_page'),
    ];
  }
  if ($entity->getType() === 'wsdl_docs_operation') {
    $build['#attached']['library'][] = 'wsdl_docs/wsdl_docs';
  }
}

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

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