function lingotek_test_lingotek_content_entity_translation_presave in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 4.0.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 3.0.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 3.1.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 3.2.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 3.3.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 3.4.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 3.5.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 3.6.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 3.7.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
- 3.8.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_translation_presave()
Implements hook_lingotek_content_entity_translation_presave().
If the translation being saved is a press release, and it is the first time it is downloaded, always save them unpublished.
File
- tests/
modules/ lingotek_test/ lingotek_test.module, line 13
Code
function lingotek_test_lingotek_content_entity_translation_presave(ContentEntityInterface &$translation, $langcode, $data) {
if ($translation
->getEntityTypeId() === 'node' && $translation
->bundle() === 'press_release') {
if ($translation
->isNewTranslation()) {
/** @var \Drupal\node\NodeInterface $translation */
$translation
->setPublished(FALSE);
}
}
}