Commit a85e59d4 authored by alexpott's avatar alexpott

Issue #2397729 by penyaskito, Gábor Hojtsy, plach, Kristen Pol: Content...

Issue #2397729 by penyaskito, Gábor Hojtsy, plach, Kristen Pol: Content language settings cannot be configured for non-translatable types on the one page configuration form
parent 1a18f03e
......@@ -16,19 +16,6 @@
*/
class FeedForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
// @todo Allow non translatable entity types having language support to be
// configured in the content language setting.
// Ensure the language widget is displayed.
$form['langcode']['#access'] = TRUE;
return $form;
}
/**
* {@inheritdoc}
*/
......
......@@ -49,6 +49,15 @@ protected function setUp() {
* Tests creation of feeds with a language.
*/
public function testFeedLanguage() {
$admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer news feeds', 'access news feeds', 'create article content']);
$this->drupalLogin($admin_user);
// Enable language selection for feeds.
$edit['entity_types[aggregator_feed]'] = TRUE;
$edit['settings[aggregator_feed][aggregator_feed][settings][language][language_alterable]'] = TRUE;
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
/** @var \Drupal\aggregator\FeedInterface[] $feeds */
$feeds = array();
// Create feeds.
......
......@@ -87,11 +87,15 @@ function _content_translation_form_language_content_settings_form_alter(array &$
$entity_type = $entity_manager->getDefinition($entity_type_id);
$storage_definitions = $entity_type instanceof ContentEntityTypeInterface ? $entity_manager->getFieldStorageDefinitions($entity_type_id) : array();
$entity_type_translatable = $entity_type->isTranslatable();
foreach (entity_get_bundles($entity_type_id) as $bundle => $bundle_info) {
// Here we do not want the widget to be altered and hold also the "Enable
// translation" checkbox, which would be redundant. Hence we add this key
// to be able to skip alterations.
$form['settings'][$entity_type_id][$bundle]['settings']['language']['#content_translation_skip_alter'] = TRUE;
if (!$entity_type_translatable) {
continue;
}
$fields = $entity_manager->getFieldDefinitions($entity_type_id, $bundle);
if ($fields) {
......@@ -167,6 +171,7 @@ function _content_translation_preprocess_language_content_settings_table(&$varia
}
else {
$translatable = array(
'data' => t('N/A'),
'class' => array('untranslatable'),
);
array_unshift($rows[$bundle]['data'], $translatable);
......
......@@ -256,6 +256,14 @@ function testFieldTranslatableSettingsUI() {
$this->assertNoText('To enable translation of this field, enable language support for this type.', 'Translatable setting for field available.');
}
/**
* Tests the translatable settings checkbox for untranslatable entities.
*/
function testNonTranslatableTranslationSettingsUI() {
$this->drupalGet('admin/config/regional/content-language');
$this->assertNoField('settings[entity_test][entity_test][translatable]');
}
/**
* Returns the entity manager.
*
......
......@@ -7,6 +7,7 @@
namespace Drupal\language\Form;
use Drupal\Core\Entity\ContentEntityTypeInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
......@@ -62,7 +63,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$bundles = $this->entityManager->getAllBundleInfo();
$language_configuration = array();
foreach ($entity_types as $entity_type_id => $entity_type) {
if (!$entity_type->isTranslatable()) {
if (!$entity_type instanceof ContentEntityTypeInterface || !$entity_type->hasKey('langcode')) {
continue;
}
$labels[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
......
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