function eck_entity_view_alter in Entity Construction Kit (ECK) 7.2
Same name and namespace in other branches
- 8 eck.module \eck_entity_view_alter()
- 7.3 eck.module \eck_entity_view_alter()
Implements hook_entity_view_alter().
File
- ./
eck.module, line 868
Code
function eck_entity_view_alter(&$build, $entity_type) {
// Return early if we don't have to add contextual links.
if (!module_exists('contextual') || !user_access('access contextual links')) {
return;
}
$entity_types = EntityType::loadAll();
foreach ($entity_types as $et) {
if ($et->name == $entity_type) {
$entity = $build['#entity'];
$this_bundle = $entity
->bundle();
// Lets add contextual links to our entities in eck you can change
// the paths of any of the possible operations, since contextual links
// are dependent on the hierarchy of those paths, changing the paths
// could cause of contextual links not to work correctly.
$build['#contextual_links']['eck'] = array(
"{$entity_type}/{$this_bundle}",
array(
entity_id($entity_type, $entity),
),
);
}
}
}