protected function LingotekNodeCohesionTranslationTest::createCohesionField in Lingotek Translation 3.7.x
Same name and namespace in other branches
- 4.0.x tests/src/Functional/LingotekNodeCohesionTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeCohesionTranslationTest::createCohesionField()
- 3.3.x tests/src/Functional/LingotekNodeCohesionTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeCohesionTranslationTest::createCohesionField()
- 3.4.x tests/src/Functional/LingotekNodeCohesionTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeCohesionTranslationTest::createCohesionField()
- 3.5.x tests/src/Functional/LingotekNodeCohesionTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeCohesionTranslationTest::createCohesionField()
- 3.6.x tests/src/Functional/LingotekNodeCohesionTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeCohesionTranslationTest::createCohesionField()
- 3.8.x tests/src/Functional/LingotekNodeCohesionTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekNodeCohesionTranslationTest::createCohesionField()
1 call to LingotekNodeCohesionTranslationTest::createCohesionField()
- LingotekNodeCohesionTranslationTest::setUp in tests/
src/ Functional/ LingotekNodeCohesionTranslationTest.php
File
- tests/
src/ Functional/ LingotekNodeCohesionTranslationTest.php, line 237
Class
- LingotekNodeCohesionTranslationTest
- Tests translating a node with multiple locales including paragraphs.
Namespace
Drupal\Tests\lingotek\FunctionalCode
protected function createCohesionField($entity_type_id, $bundle, $field_name = 'layout_canvas', $field_label = 'Layout canvas', $target_entity_type = 'cohesion_layout', $selection_handler = 'default', $selection_handler_settings = [], $cardinality = 1) {
// Look for or add the specified field to the requested entity bundle.
if (!FieldStorageConfig::loadByName($entity_type_id, $field_name)) {
FieldStorageConfig::create([
'field_name' => $field_name,
'type' => 'cohesion_entity_reference_revisions',
'entity_type' => $entity_type_id,
'cardinality' => $cardinality,
'settings' => [
'target_type' => $target_entity_type,
],
])
->save();
}
if (!FieldConfig::loadByName($entity_type_id, $bundle, $field_name)) {
FieldConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type_id,
'bundle' => $bundle,
'label' => $field_label,
'settings' => [
'handler' => $selection_handler,
'handler_settings' => $selection_handler_settings,
],
])
->save();
}
EntityFormDisplay::load("{$entity_type_id}.{$bundle}.default")
->setComponent($field_name, [
'type' => 'cohesion_layout_builder_widget',
'weight' => 1,
])
->save();
EntityViewDisplay::load("{$entity_type_id}.{$bundle}.default")
->setComponent($field_name, [
'label' => 'hidden',
'type' => 'entity_reference_revisions_entity_view',
])
->save();
}