farmOS/modules/quick/movement/farm_quick_movement.module

25 lines
794 B
PHP

<?php
/**
* @file
* Contains farm_quick_movement.module.
*/
use Drupal\Core\Entity\EntityTypeInterface;
/**
* Implements hook_entity_base_field_info_alter().
*/
function farm_quick_movement_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
// Add "Move" button to asset "Current location" field formatter which
// redirects to the Movement quick form.
if ($entity_type->id() == 'asset' && !empty($fields['location'])) {
$display_options = $fields['location']->getDisplayOptions('view');
$display_options['type'] = 'asset_current_location_move';
$display_options['settings']['move_asset_button'] = TRUE;
$fields['location']->setDisplayOptions('view', $display_options);
}
}