Commit 27f49f79 authored by gbyte.co's avatar gbyte.co

Some code cleaning.

parent c4f1a83d
......@@ -25,22 +25,26 @@ abstract class EntityLinkGenerator {
}
$links = $this->get_entity_bundle_links($entity_type, $bundle, $language);
$lastmod = NULL;
foreach ($links as $id => &$link) {
switch ($entity_type) {
case 'node':
$lastmod = db_query("SELECT changed FROM {node_field_data} WHERE nid = :nid LIMIT 1", array(':nid' => $id))->fetchCol();
break;
case 'taxonomy_term':
$lastmod = db_query("SELECT changed FROM {taxonomy_term_field_data} WHERE tid = :tid LIMIT 1", array(':tid' => $id))->fetchCol();
break;
case 'menu':
//todo: to be implemented
}
$this->entity_links[] = SitemapGenerator::add_xml_link_markup($link, $bundle_settings['priority'], isset($lastmod[0]) ? date_iso8601($lastmod[0]) : NULL);
foreach ($links as $id => $link) {
$this->entity_links[] = SitemapGenerator::add_xml_link_markup($link, $bundle_settings['priority'], $this->get_lastmod($entity_type, $id));
}
}
return $this->entity_links;
}
private function get_lastmod($entity_type, $id) {
switch ($entity_type) {
case 'node':
$lastmod = db_query("SELECT changed FROM {node_field_data} WHERE nid = :nid LIMIT 1", array(':nid' => $id))->fetchCol();
break;
case 'taxonomy_term':
$lastmod = db_query("SELECT changed FROM {taxonomy_term_field_data} WHERE tid = :tid LIMIT 1", array(':tid' => $id))->fetchCol();
break;
case 'menu':
//todo: to be implemented
}
return isset($lastmod[0]) ? date_iso8601($lastmod[0]) : NULL;
}
abstract function get_entity_bundle_links($entity_type, $bundle, $language);
}
......@@ -20,7 +20,6 @@ class taxonomy_term extends EntityLinkGenerator {
function get_entity_bundle_links($entity_type, $bundle, $language) {
//todo: check what happens if none existent.
$results = db_query("SELECT tid FROM {taxonomy_term_field_data} WHERE vid = :vid", array(':vid' => $bundle))
->fetchAllAssoc('tid');
......
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