Commit 39268b17 authored by alexpott's avatar alexpott
Browse files

Issue #2256023 by olli, Gábor Hojtsy, estoyausente, adci_contributor: Content...

Issue #2256023 by olli, Gábor Hojtsy, estoyausente, adci_contributor: Content translation operation is only available for nodes, not other entity types such as custom blocks
parent 315c2a84
......@@ -135,6 +135,10 @@ protected function doTestBasicTranslation() {
catch (\Exception $e) {
$this->fail($message);
}
// Check that the translate operation link is shown.
$this->drupalGet('admin/structure/block/block-content');
$this->assertLinkByHref('block/' . $entity->id() . '/translations');
}
/**
......
......@@ -12,7 +12,6 @@
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\node\NodeInterface;
/**
* Implements hook_help().
......@@ -161,16 +160,18 @@ function content_translation_field_info_alter(&$info) {
}
/**
* Implements hook_entity_operation_alter().
* Implements hook_entity_operation().
*/
function content_translation_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {
// @todo Use an access permission.
if ($entity instanceof NodeInterface && $entity->isTranslatable()) {
function content_translation_entity_operation(EntityInterface $entity) {
$operations = array();
if ($entity->hasLinkTemplate('drupal:content-translation-overview') && content_translation_translate_access($entity)->isAllowed()) {
$operations['translate'] = array(
'title' => t('Translate'),
'url' => $entity->urlInfo('drupal:content-translation-overview'),
'weight' => 50,
);
}
return $operations;
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment