Add help text to /assets, /logs, /quantities, and /plans.

This commit is contained in:
Michael Stenta 2021-09-20 16:42:36 -04:00
parent b966281d77
commit a54e1c0a62
1 changed files with 50 additions and 0 deletions

View File

@ -6,8 +6,58 @@
*/
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\views\ViewExecutable;
/**
* Implements hook_help().
*/
function farm_ui_views_help($route_name, RouteMatchInterface $route_match) {
$output = '';
// Define route names and URLs for primary entity types.
$entity_routes = [
'asset' => 'entity.asset.collection',
'log' => 'entity.log.collection',
'quantity' => 'view.farm_quantity.page',
'plan' => 'entity.plan.collection',
'people' => 'view.farm_people.page',
];
$entity_urls = [
'asset' => Url::fromRoute($entity_routes['asset'])->toString(),
'log' => Url::fromRoute($entity_routes['log'])->toString(),
'quantity' => Url::fromRoute($entity_routes['quantity'])->toString(),
'plan' => Url::fromRoute($entity_routes['plan'])->toString(),
'people' => Url::fromRoute($entity_routes['people'])->toString(),
];
// Assets View.
if ($route_name == $entity_routes['asset']) {
$output .= '<p>' . t('Assets represent things that are being tracked or managed. They store high-level information, but most historical data is stored in the <a href=":logs">logs</a> that reference them.', [':logs' => $entity_urls['log']]) . '</p>';
$output .= '<p>' . t('Assets that are no longer active can be archived. Archived assets will be hidden from most lists, but are preserved and searchable for posterity.') . '</p>';
}
// Logs View.
if ($route_name == $entity_routes['log']) {
$output .= '<p>' . t('Logs represent events that take place in relation to <a href=":assets">assets</a> and other records. They have a timestamp to represent when they take place, and can be marked as "Pending" or "Done" for planning purposes.', [':assets' => $entity_urls['asset']]) . '</p>';
$output .= '<p>' . t('Logs can be assigned to <a href=":people">people</a> for task management purposes.', [':people' => $entity_urls['people']]) . '</p>';
}
// Quantities View.
if ($route_name == $entity_routes['quantity']) {
$output .= '<p>' . t('Quantities are granular units of quantitative data that represent a single data point within a <a href=":logs">log</a>.', [':logs' => $entity_urls['log']]) . '</p>';
$output .= '<p>' . t('All quantities can optionally include a measure, value, units, and label. Specific quantity types may collect additional information.') . '</p>';
}
// Plans View.
if ($route_name == $entity_routes['plan']) {
$output .= '<p>' . t('Plans provide features for planning, managing, and organizing <a href=":assets">assets</a>, <a href=":logs">logs</a>, and <a href=":people">people</a> around a particular goal.', [':assets' => $entity_urls['asset'], ':logs' => $entity_urls['log'], ':people' => $entity_urls['people']]) . '</p>';
}
return $output;
}
/**
* Implements hook_entity_type_build().
*/