Problem/Motivation
Currently the translate operation link is available only for nodes. See:
function content_translation_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {
// @todo Use an access permission.
if ($entity instanceof NodeInterface && $entity->isTranslatable()) {
$operations['translate'] = array(
'title' => t('Translate'),
'url' => $entity->urlInfo('drupal:content-translation-overview'),
);
}
}
Proposed resolution
1. Implement hook_entity_operation() instead.
2. Instead of relying on NodeInterface and $entity->isTranslatable(), use content_translation_translate_access() and look for the link template.
3. Add tests.
Remaining tasks
Commit.
User interface changes
Translate operation will show among entity operations, such as this operation list for blocks:
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#13 | 2256023-13.patch | 2.01 KB | adci_contributor |
#11 | CustomBlock.png | 117.32 KB | Gábor Hojtsy |
#8 | interdiff.txt | 1.53 KB | olli |
#8 | 2256023-8.patch | 2.06 KB | olli |
#8 | 2256023-8-test_only.patch | 684 bytes | olli |
Comments
Comment #1
larowlanWill need tests
Comment #2
olli CreditAttribution: olli commentedRerolled and added the hasLinkTemplate() check.
Comment #3
Jalandhar CreditAttribution: Jalandhar commentedPatch needs to be updated again.
Comment #4
estoyausenteRerolled.
Comment #5
estoyausenteComment #6
star-szrThanks @estoyausente. Tagging for test coverage.
Comment #7
Gábor HojtsyThis is a great patch. Also a good find! Still needs tests though.
Comment #8
olli CreditAttribution: olli commentedAdded a small test.
Comment #10
Gábor HojtsyYay, looks great :) Thanks!
Comment #11
Gábor HojtsyComment #12
alexpottNeeds a reroll.
Comment #13
adci_contributor CreditAttribution: adci_contributor commentedTrying to reroll
Comment #14
Gábor HojtsyThanks.
Comment #15
alexpottThis issue is a normal bug fix, and doesn't include any disruptive changes, so it is allowed per https://www.drupal.org/core/beta-changes. Committed 39268b1 and pushed to 8.0.x. Thanks!
Comment #17
Gábor HojtsyThanks all! Superb!