function commerce_autosku_entity_operation in Commerce AutoSKU 8.2
Implements hook_entity_operation().
File
- ./
commerce_autosku.module, line 169 - Allows hiding of entity label fields and automatic label creation.
Code
function commerce_autosku_entity_operation(EntityInterface $entity) {
$operations = array();
$entity_type = $entity
->getEntityType();
$entity_type_id = $entity_type
->id();
$entity_id = $entity
->id();
if ($entity
->hasLinkTemplate('auto-sku') && \Drupal::currentUser()
->hasPermission('administer ' . $entity_type_id . ' SKU')) {
$operations['auto-sku'] = array(
'title' => t('Manage automatic SKU'),
'weight' => 100,
'url' => Url::fromRoute("entity.{$entity_type_id}.auto_sku", array(
$entity_type_id => $entity_id,
)),
);
}
return $operations;
}