class ContactLocalTaskProvider in CRM Core 8.3
Provides a set of tasks to view, edit and duplicate an entity.
Hierarchy
- class \Drupal\entity\Menu\DefaultEntityLocalTaskProvider implements EntityHandlerInterface, EntityLocalTaskProviderInterface uses StringTranslationTrait
- class \Drupal\crm_core_contact\Menu\ContactLocalTaskProvider
Expanded class hierarchy of ContactLocalTaskProvider
1 file declares its use of ContactLocalTaskProvider
- LocalTaskTest.php in modules/
crm_core_contact/ tests/ src/ Kernel/ LocalTaskTest.php
File
- modules/
crm_core_contact/ src/ Menu/ ContactLocalTaskProvider.php, line 11
Namespace
Drupal\crm_core_contact\MenuView source
class ContactLocalTaskProvider extends DefaultEntityLocalTaskProvider {
/**
* {@inheritdoc}
*/
public function buildLocalTasks(EntityTypeInterface $entity_type) {
// See #1834002 and #3044371 for context.
$link_templates = [];
$types = [
'canonical',
'edit-form',
'duplicate-form',
'delete-form',
'version-history',
];
foreach ($types as $type) {
if ($entity_type
->hasLinkTemplate($type)) {
$link_templates[] = str_replace('-', '_', $type);
}
}
$tasks = [];
if (count($link_templates) > 1) {
$entity_type_id = $entity_type
->id();
$base = reset($link_templates);
$titles = [
'canonical' => $this
->t('View'),
'edit_form' => $this
->t('Edit'),
'duplicate_form' => $this
->t('Duplicate'),
'delete_form' => $this
->t('Delete'),
'version_history' => $this
->t('Revisions'),
];
$weight = 0;
foreach ($link_templates as $template) {
$route_name = "entity.{$entity_type_id}.{$template}";
$tasks[$route_name] = [
'title' => $titles[$template],
'route_name' => $route_name,
'base_route' => "entity.{$entity_type_id}.{$base}",
'weight' => $weight,
];
$weight += 10;
}
}
return $tasks;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContactLocalTaskProvider:: |
public | function |
Builds local tasks for the given entity type. Overrides DefaultEntityLocalTaskProvider:: |
|
DefaultEntityLocalTaskProvider:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface:: |
|
DefaultEntityLocalTaskProvider:: |
public | function | Constructs a DefaultEntityLocalTaskProvider object. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |