Commit 5ec5d930 authored by andrei.dincu's avatar andrei.dincu
Browse files

Issue #2249723 by andrei.dincu: XmlSitemapEntitiesSettingsForm works fine (before mentors feedback)

parent 975e7bb6
...@@ -81,7 +81,10 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container ...@@ -81,7 +81,10 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
} }
$labels[$entity_type_id] = $entity_type->getLabel() ? : $entity_type_id; $labels[$entity_type_id] = $entity_type->getLabel() ? : $entity_type_id;
$default[$entity_type_id] = FALSE;
if (\Drupal::state()->get('xmlsitemap_entity_' . $entity_type_id,0)) {
$default[] = $entity_type_id;
}
} }
asort($labels); asort($labels);
...@@ -104,10 +107,9 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container ...@@ -104,10 +107,9 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
$entity_type = $entity_types[$entity_type_id]; $entity_type = $entity_types[$entity_type_id];
$form['settings'][$entity_type_id] = array( $form['settings'][$entity_type_id] = array(
'#title' => $label,
'#type' => 'container', '#type' => 'container',
'#entity_type' => $entity_type_id, '#entity_type' => $entity_type_id,
'#theme' => 'language_content_settings_table', '#theme' => 'xmlsitemap_content_settings_table',
'#bundle_label' => $entity_type->getBundleLabel() ? : $label, '#bundle_label' => $entity_type->getBundleLabel() ? : $label,
'#states' => array( '#states' => array(
'visible' => array( 'visible' => array(
...@@ -115,19 +117,14 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container ...@@ -115,19 +117,14 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
), ),
), ),
); );
foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) { foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
$form['settings'][$entity_type_id][$bundle]['settings'] = array( $form['settings'][$entity_type_id][$bundle]['settings'] = array(
'#type' => 'item', '#type' => 'item',
'#label' => $bundle_info['label'], '#label' => $bundle_info['label'],
'language' => array( 'bundle' => array(
'#type' => 'language_configuration', '#type' => 'checkbox',
'#entity_information' => array( '#default_value' => \Drupal::state()->get('xmlsitemap_entity_' . $entity_type_id . '_bundle_' . $bundle,0)
'entity_type' => $entity_type_id,
'bundle' => $bundle,
), ),
'#default_value' => $language_configuration[$entity_type_id][$bundle],
),
); );
} }
} }
...@@ -139,9 +136,14 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container ...@@ -139,9 +136,14 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
} }
public function submitForm(array &$form, array &$form_state) { public function submitForm(array &$form, array &$form_state) {
$values = $form_state['values']['custom_entity_types']; $bundles = $this->entityManager->getAllBundleInfo();
foreach ($this->entities as $entity) { $entity_values = $form_state['values']['entity_types'];
\Drupal::state()->set('xmlsitemap_entity_' . $entity, $values[$entity] ? TRUE : FALSE); foreach ($entity_values as $key => $value) {
\Drupal::state()->set('xmlsitemap_entity_' . $key, $value);
foreach ($bundles[$key] as $bundle_key => $bundle_value) {
\Drupal::state()->set('xmlsitemap_entity_' . $key . '_bundle_' . $bundle_key,
$form_state['values']['settings'][$key][$bundle_key]['settings']['bundle']);
}
} }
parent::submitForm($form, $form_state); parent::submitForm($form, $form_state);
} }
......
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