Commit cb01f4da authored by gbyte.co's avatar gbyte.co

Issue #2855015: Latest dev version requires Drupal 8.3.x

parent 9f9e8dae
......@@ -10,7 +10,6 @@ services:
- '@entity_type.manager'
- '@path.validator'
- '@date.formatter'
- '@datetime.time'
simple_sitemap.sitemap_generator:
class: Drupal\simple_sitemap\SitemapGenerator
......@@ -20,7 +19,6 @@ services:
- '@database'
- '@module_handler'
- '@language_manager'
- '@datetime.time'
simple_sitemap.form_helper:
class: Drupal\simple_sitemap\Form\FormHelper
......
......@@ -10,7 +10,6 @@ use Drupal\Core\Path\PathValidator;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\Component\Datetime\Time;
/**
* Class Simplesitemap.
......@@ -25,7 +24,6 @@ class Simplesitemap {
private $entityQuery;
private $entityTypeManager;
private $pathValidator;
private $time;
private static $allowed_link_settings = [
'entity' => ['index', 'priority'],
'custom' => ['priority'],
......@@ -33,7 +31,6 @@ class Simplesitemap {
/**
* Simplesitemap constructor.
*
* @param \Drupal\simple_sitemap\SitemapGenerator $sitemapGenerator
* @param \Drupal\Core\Config\ConfigFactory $configFactory
* @param \Drupal\Core\Database\Connection $database
......@@ -41,7 +38,6 @@ class Simplesitemap {
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* @param \Drupal\Core\Path\PathValidator $pathValidator
* @param \Drupal\Core\Datetime\DateFormatter $dateFormatter
* @param \Drupal\Component\Datetime\Time $time
*/
public function __construct(
SitemapGenerator $sitemapGenerator,
......@@ -50,8 +46,7 @@ class Simplesitemap {
QueryFactory $entityQuery,
EntityTypeManagerInterface $entityTypeManager,
PathValidator $pathValidator,
DateFormatter $dateFormatter,
Time $time
DateFormatter $dateFormatter
) {
$this->sitemapGenerator = $sitemapGenerator;
$this->configFactory = $configFactory;
......@@ -60,7 +55,6 @@ class Simplesitemap {
$this->entityTypeManager = $entityTypeManager;
$this->pathValidator = $pathValidator;
$this->dateFormatter = $dateFormatter;
$this->time = $time;
}
/**
......@@ -478,7 +472,7 @@ class Simplesitemap {
*/
public function getEntityInstanceBundleName($entity) {
return $entity->getEntityTypeId() == 'menu_link_content'
// Menu fix.
// Menu fix.
? $entity->getMenuName() : $entity->bundle();
}
......@@ -490,7 +484,7 @@ class Simplesitemap {
*/
public function getBundleEntityTypeId($entity) {
return $entity->getEntityTypeId() == 'menu'
// Menu fix.
// Menu fix.
? 'menu_link_content' : $entity->getEntityType()->getBundleOf();
}
......@@ -508,7 +502,7 @@ class Simplesitemap {
*/
public function getSitemap($chunk_id = NULL) {
$chunks = $this->fetchSitemapChunks();
if (null === $chunk_id || !isset($chunks[$chunk_id])) {
if (is_null($chunk_id) || !isset($chunks[$chunk_id])) {
// Return sitemap index, if there are multiple sitemap chunks.
if (count($chunks) > 1) {
......@@ -603,7 +597,7 @@ class Simplesitemap {
$chunks = $this->fetchSitemapChunks();
if (isset($chunks[1]->sitemap_created)) {
return $this->dateFormatter
->formatInterval($this->time->getRequestTime() - $chunks[1]->sitemap_created);
->formatInterval(REQUEST_TIME - $chunks[1]->sitemap_created);
}
return FALSE;
}
......
......@@ -7,7 +7,6 @@ use Drupal\simple_sitemap\Batch\Batch;
use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Component\Datetime\Time;
/**
* Class SitemapGenerator.
......@@ -29,7 +28,6 @@ class SitemapGenerator {
private $generateFrom = 'form';
private $isHreflangSitemap;
private $generator;
private $time;
/**
* SitemapGenerator constructor.
......@@ -37,21 +35,18 @@ class SitemapGenerator {
* @param \Drupal\Core\Database\Connection $database
* @param \Drupal\Core\Extension\ModuleHandler $module_handler
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* @param \Drupal\Component\Datetime\Time $time
*/
public function __construct(
Batch $batch,
Connection $database,
ModuleHandler $module_handler,
LanguageManagerInterface $language_manager,
Time $time
LanguageManagerInterface $language_manager
) {
$this->batch = $batch;
$this->db = $database;
$this->moduleHandler = $module_handler;
$this->defaultLanguageId = $language_manager->getDefaultLanguage()->getId();
$this->isHreflangSitemap = count($language_manager->getLanguages()) > 1;
$this->time = $time;
}
/**
......@@ -161,7 +156,7 @@ class SitemapGenerator {
$values = [
'id' => $remove_sitemap ? 1 : $this->db->query('SELECT MAX(id) FROM {simple_sitemap}')->fetchField() + 1,
'sitemap_string' => $this->generateSitemapChunk($links),
'sitemap_created' => $this->time->getRequestTime(),
'sitemap_created' => REQUEST_TIME,
];
if ($remove_sitemap) {
$this->db->truncate('simple_sitemap')->execute();
......
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