bibcite-8.x-1.x-dev/modules/bibcite_import/bibcite_import.module

modules/bibcite_import/bibcite_import.module
<?php

/**
 * @file
 * Module hooks implementations.
 */

use Drupal\bibcite_entity\Entity\ReferenceInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_bibcite_reference_prepare_form().
 *
 * Populate form values from tempstore.
 */
function bibcite_import_bibcite_reference_prepare_form(ReferenceInterface $entity, $operation, FormStateInterface $form_state) {
  /** @var \Drupal\Core\TempStore\PrivateTempStore $temp_storage */
  $temp_storage = \Drupal::service('tempstore.private')->get('bibcite_entity_populate');
  $current_user_id = \Drupal::currentUser()->id();
  $populated_entity = $temp_storage->get($current_user_id);
  if ($populated_entity && $populated_entity instanceof ReferenceInterface) {
    foreach ($populated_entity->getFields() as $field_name => $field) {
      $entity->set($field_name, $field->getValue());
    }

    $temp_storage->delete($current_user_id);
  }
}

/**
 * Implements hook_help().
 */
function bibcite_import_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.bibcite_import':
      $module = 'bibcite_import';
      return \Drupal::service('bibcite.help_service')
        ->getHelpMarkup([], $route_name, $module);
  }
}

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

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