Commit 3ba57805 authored by gbyte.co's avatar gbyte.co

Fix warning when visiting indexable menu page

parent 9ea1c5a7
...@@ -9,7 +9,6 @@ services: ...@@ -9,7 +9,6 @@ services:
- '@config.factory' - '@config.factory'
- '@database' - '@database'
- '@entity_type.manager' - '@entity_type.manager'
- '@entity_type.bundle.info'
- '@path.validator' - '@path.validator'
- '@date.formatter' - '@date.formatter'
- '@datetime.time' - '@datetime.time'
......
...@@ -48,12 +48,24 @@ class EntityHelper { ...@@ -48,12 +48,24 @@ class EntityHelper {
} }
/** /**
* @param string $entity_type_name * @param string $entity_type_id
* @return array
*/
public function getBundleInfo($entity_type_id) {
return $this->entityTypeBundleInfo->getBundleInfo($entity_type_id);
}
/**
* @param string $entity_type_id
* @param string $bundle_name * @param string $bundle_name
* @return mixed * @return mixed
*/ */
public function getBundleLabel($entity_type_name, $bundle_name) { public function getBundleLabel($entity_type_id, $bundle_name) {
return $this->entityTypeBundleInfo->getBundleInfo($entity_type_name)[$bundle_name]['label']; $entity_info = $this->getBundleInfo($entity_type_id);
return isset($entity_info[$bundle_name]['label'])
? $entity_info[$bundle_name]['label']
: $bundle_name; // Menu fix.
} }
/** /**
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
namespace Drupal\simple_sitemap; namespace Drupal\simple_sitemap;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\simple_sitemap\Queue\QueueWorker; use Drupal\simple_sitemap\Queue\QueueWorker;
use Drupal\Core\Path\PathValidator; use Drupal\Core\Path\PathValidator;
...@@ -48,11 +47,6 @@ class Simplesitemap { ...@@ -48,11 +47,6 @@ class Simplesitemap {
*/ */
protected $entityTypeManager; protected $entityTypeManager;
/**
* @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
*/
protected $entityTypeBundleInfo;
/** /**
* @var \Drupal\Core\Path\PathValidator * @var \Drupal\Core\Path\PathValidator
*/ */
...@@ -104,7 +98,6 @@ class Simplesitemap { ...@@ -104,7 +98,6 @@ class Simplesitemap {
* @param \Drupal\Core\Config\ConfigFactory $config_factory * @param \Drupal\Core\Config\ConfigFactory $config_factory
* @param \Drupal\Core\Database\Connection $database * @param \Drupal\Core\Database\Connection $database
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* @param \Drupal\Core\Path\PathValidator $path_validator * @param \Drupal\Core\Path\PathValidator $path_validator
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter * @param \Drupal\Core\Datetime\DateFormatter $date_formatter
* @param \Drupal\Component\Datetime\Time $time * @param \Drupal\Component\Datetime\Time $time
...@@ -117,7 +110,6 @@ class Simplesitemap { ...@@ -117,7 +110,6 @@ class Simplesitemap {
ConfigFactory $config_factory, ConfigFactory $config_factory,
Connection $database, Connection $database,
EntityTypeManagerInterface $entity_type_manager, EntityTypeManagerInterface $entity_type_manager,
EntityTypeBundleInfoInterface $entity_type_bundle_info,
PathValidator $path_validator, PathValidator $path_validator,
DateFormatter $date_formatter, DateFormatter $date_formatter,
Time $time, Time $time,
...@@ -129,7 +121,6 @@ class Simplesitemap { ...@@ -129,7 +121,6 @@ class Simplesitemap {
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
$this->db = $database; $this->db = $database;
$this->entityTypeManager = $entity_type_manager; $this->entityTypeManager = $entity_type_manager;
$this->entityTypeBundleInfo = $entity_type_bundle_info;
$this->pathValidator = $path_validator; $this->pathValidator = $path_validator;
$this->dateFormatter = $date_formatter; $this->dateFormatter = $date_formatter;
$this->time = $time; $this->time = $time;
...@@ -531,14 +522,8 @@ class Simplesitemap { ...@@ -531,14 +522,8 @@ class Simplesitemap {
->get("simple_sitemap.bundle_settings.$variant.$entity_type_id.$bundle_name") ->get("simple_sitemap.bundle_settings.$variant.$entity_type_id.$bundle_name")
->get(); ->get();
// If not found and entity type is enabled, return default bundle settings.
if (empty($bundle_settings) && $supplement_defaults) { if (empty($bundle_settings) && $supplement_defaults) {
if (isset($this->entityTypeBundleInfo->getBundleInfo($entity_type_id)[$bundle_name])) { self::supplementDefaultSettings('entity', $bundle_settings);
self::supplementDefaultSettings('entity', $bundle_settings);
}
else {
$bundle_settings = NULL;
}
} }
} }
else { else {
...@@ -552,7 +537,7 @@ class Simplesitemap { ...@@ -552,7 +537,7 @@ class Simplesitemap {
// Supplement default bundle settings for all bundles not found in simple_sitemap.bundle_settings.*.* configuration. // Supplement default bundle settings for all bundles not found in simple_sitemap.bundle_settings.*.* configuration.
if ($supplement_defaults) { if ($supplement_defaults) {
foreach ($this->entityHelper->getSupportedEntityTypes() as $type_id => $type_definition) { foreach ($this->entityHelper->getSupportedEntityTypes() as $type_id => $type_definition) {
foreach($this->entityTypeBundleInfo->getBundleInfo($type_id) as $bundle => $bundle_definition) { foreach($this->entityHelper->getBundleInfo($type_id) as $bundle => $bundle_definition) {
if (!isset($bundle_settings[$type_id][$bundle])) { if (!isset($bundle_settings[$type_id][$bundle])) {
self::supplementDefaultSettings('entity', $bundle_settings[$type_id][$bundle]); self::supplementDefaultSettings('entity', $bundle_settings[$type_id][$bundle]);
} }
......
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