Commit 3c745fc1 authored by Fabien Gutknecht's avatar Fabien Gutknecht
Browse files

Issue #3299295 by Project Update Bot: Automated Drupal 10 compatibility fixes

parent b84ab1b6
Loading
Loading
Loading
Loading
+25 −3
Original line number Diff line number Diff line
@@ -7,6 +7,8 @@ use Drupal\Core\Entity\ContentEntityType;
use Drupal\Core\Entity\EntityDisplayRepositoryInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Extension\ThemeExtensionList;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\File\FileSystem;

@@ -65,6 +67,20 @@ class TemplateGeneratorManager {
   */
  protected $fileSystem;

  /**
   * An extension discovery instance.
   *
   * @var \Drupal\Core\Extension\ThemeExtensionList
   */
  protected ThemeExtensionList $themeList;

  /**
   * The renderer.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected RendererInterface $renderer;

  /**
   * Constructs a TemplateGeneratorManager.
   *
@@ -82,8 +98,12 @@ class TemplateGeneratorManager {
   *   The config.
   * @param \Drupal\Core\File\FileSystem $file_system
   *   The file system.
   * @param \Drupal\Core\Extension\ThemeExtensionList $theme_list
   *   The theme extension list.
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer.
   */
  public function __construct($root, StateInterface $state, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info, ConfigFactoryInterface $config, FileSystem $file_system) {
  public function __construct(string $root, StateInterface $state, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository, EntityTypeBundleInfoInterface $entity_type_bundle_info, ConfigFactoryInterface $config, FileSystem $file_system, ThemeExtensionList $theme_list, RendererInterface $renderer) {
    $this->root = $root;
    $this->state = $state;
    $this->entityTypeManager = $entity_type_manager;
@@ -91,6 +111,8 @@ class TemplateGeneratorManager {
    $this->entityTypeBundleInfo = $entity_type_bundle_info;
    $this->themeConfig = $config->get('system.theme');
    $this->fileSystem = $file_system;
    $this->themeList = $theme_list;
    $this->renderer = $renderer;
  }

  /**
@@ -158,7 +180,7 @@ class TemplateGeneratorManager {
      if ((!isset($ignore['bundle'][$bundle_id]) or $ignore['bundle'][$bundle_id] === 0)
        && (!isset($ignore['viewmode'][$view_mode]) or $ignore['viewmode'][$view_mode] === 0)) {

        $parent_path = $this->root . '/' . drupal_get_path('theme', $this->themeConfig->get('default'));
        $parent_path = $this->root . '/' . $this->themeList->getPath($this->themeConfig->get('default'));

        $html = NULL;
        $view_mode_tpl = str_replace('_', '-', $view_mode);
@@ -307,7 +329,7 @@ class TemplateGeneratorManager {
        // Set information for this entity.
        if (isset($data[$definition->id()]['bundles'])) {
          $label = $definition->getLabel();
          $data[$definition->id()]['name'] = render($label);
          $data[$definition->id()]['name'] = $label->render();
          $data[$definition->id()]['id'] = $definition->id();

          // Set all avalaible bundle for this entity.
+1 −1
Original line number Diff line number Diff line
@@ -3,4 +3,4 @@ type: module
description: Automatic templates generation.
package: Template Generator
configure: template_generator.settings
core_version_requirement: ^8 || ^9
core_version_requirement: ^9.3 || ^10
+1 −1
Original line number Diff line number Diff line
services:
  template_generator.manager:
    class: Drupal\template_generator\TemplateGeneratorManager
    arguments: ['@app.root', '@state', '@entity_type.manager', '@entity_display.repository', '@entity_type.bundle.info', '@config.factory', '@file_system']
    arguments: ['@app.root', '@state', '@entity_type.manager', '@entity_display.repository', '@entity_type.bundle.info', '@config.factory', '@file_system', '@extension.list.theme', '@renderer']