Commit 24304eb0 authored by andrei.dincu's avatar andrei.dincu

Issue #2249723 by andrei.dincu: Few changes in...

Issue #2249723 by andrei.dincu: Few changes in xmlsitemap_xmlsitemap_index_links() and xmlsitemap_xmlsitemap_process_entity_links()
parent 8b06e1eb
......@@ -82,7 +82,7 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
$labels[$entity_type_id] = $entity_type->getLabel() ? : $entity_type_id;
if (\Drupal::state()->get('xmlsitemap_entity_' . $entity_type_id,0)) {
if (\Drupal::state()->get('xmlsitemap_entity_' . $entity_type_id, 0)) {
$default[] = $entity_type_id;
}
}
......@@ -123,8 +123,8 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
'#label' => $bundle_info['label'],
'bundle' => array(
'#type' => 'checkbox',
'#default_value' => \Drupal::state()->get('xmlsitemap_entity_' . $entity_type_id . '_bundle_' . $bundle,0)
),
'#default_value' => \Drupal::state()->get('xmlsitemap_entity_' . $entity_type_id . '_bundle_' . $bundle, 0)
),
);
}
}
......@@ -140,9 +140,15 @@ class XmlSitemapEntitiesSettingsForm extends ConfigFormBase implements Container
$entity_values = $form_state['values']['entity_types'];
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']);
if ($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']);
}
}
else {
foreach ($bundles[$key] as $bundle_key => $bundle_value) {
\Drupal::state()->set('xmlsitemap_entity_' . $key . '_bundle_' . $bundle_key, 0);
}
}
}
parent::submitForm($form, $form_state);
......
......@@ -1724,10 +1724,10 @@ function xmlsitemap_xmlsitemap_index_links($limit) {
}
$entity_bundles[] = $bundle;
}
$query = \Drupal::entityManager()->getStorage($entity_type_id)->getQuery();
$query->condition('bundle', $entity_bundles, 'in');
$entities = $query->execute();
xmlsitemap_xmlsitemap_process_entity_links($entities);
$query = \Drupal::entityManager()->getStorage($entity_type->id())->getQuery();
$query->condition('type', $entity_bundles, 'in');
$ids = $query->execute();
xmlsitemap_xmlsitemap_process_entity_links($entity_type_id, $ids);
}
}
......@@ -1737,9 +1737,10 @@ function xmlsitemap_xmlsitemap_index_links($limit) {
* @param $entities
* An array of .
*/
function xmlsitemap_xmlsitemap_process_entity_links(array $entities) {
function xmlsitemap_xmlsitemap_process_entity_links($entity_type, array $ids) {
$entities = entity_load_multiple($entity_type, $ids);
foreach ($entities as $entity) {
$link = xmlsitemap_user_create_link($entity);
$link = xmlsitemap_entity_create_link($entity);
xmlsitemap_link_save($link);
}
}
......
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