bibcite_import.module in Bibliography & Citation 8
Same filename and directory in other branches
Module hooks implementations.
File
modules/bibcite_import/bibcite_import.moduleView source
<?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);
}
}
Functions
Name | Description |
---|---|
bibcite_import_bibcite_reference_prepare_form | Implements hook_bibcite_reference_prepare_form(). |
bibcite_import_help | Implements hook_help(). |