Issue #2816447 by kriboogh: Get feed title in correct language
14 open threads
Closes #2816447
Merge request reports
Activity
added 1 commit
added 1 commit
39 58 * The entity type manager. 40 59 * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository 41 60 * The entity display repository. 61 * @param \Drupal\Core\Language\LanguageManagerInterface|null $language_manager 62 * The language manager. 63 * @param \Drupal\Core\Entity\EntityRepositoryInterface|null $entity_repository 64 * The entity repository. 42 65 */ 43 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository) { 66 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository, ?LanguageManagerInterface $language_manager = NULL, ?EntityRepositoryInterface $entity_repository = NULL) { 44 67 parent::__construct($configuration, $plugin_id, $plugin_definition); 45 68 46 69 $this->entityTypeManager = $entity_type_manager; 47 70 $this->entityDisplayRepository = $entity_display_repository; 71 if ($language_manager === NULL) { 72 @trigger_error('The language_manager service must be passed to RssPluginBase::__construct(), it is required before Drupal 10.0.0.', E_USER_WARNING); changed this line in version 4 of the diff
63 * @param \Drupal\Core\Entity\EntityRepositoryInterface|null $entity_repository 64 * The entity repository. 42 65 */ 43 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository) { 66 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository, ?LanguageManagerInterface $language_manager = NULL, ?EntityRepositoryInterface $entity_repository = NULL) { 44 67 parent::__construct($configuration, $plugin_id, $plugin_definition); 45 68 46 69 $this->entityTypeManager = $entity_type_manager; 47 70 $this->entityDisplayRepository = $entity_display_repository; 71 if ($language_manager === NULL) { 72 @trigger_error('The language_manager service must be passed to RssPluginBase::__construct(), it is required before Drupal 10.0.0.', E_USER_WARNING); 73 $language_manager = \Drupal::service('language_manager'); 74 } 75 $this->languageManager = $language_manager; 76 if ($entity_repository === NULL) { 77 @trigger_error('The entity.repository service must be passed to RssPluginBase::__construct(), it is required before Drupal 10.0.0.', E_USER_WARNING); changed this line in version 4 of the diff
26 31 */ 27 32 protected $entityDisplayRepository; 28 33 34 /** 35 * The language manager. 36 * 37 * @var \Drupal\Core\Language\LanguageManagerInterface 38 */ 39 protected $languageManager; changed this line in version 4 of the diff
26 31 */ 27 32 protected $entityDisplayRepository; 28 33 34 /** 35 * The language manager. 36 * 37 * @var \Drupal\Core\Language\LanguageManagerInterface 38 */ 39 protected $languageManager; 40 41 /** 42 * The entity repository. 43 * 44 * @var \Drupal\Core\Entity\EntityRepositoryInterface 45 */ 46 protected $entityRepository; changed this line in version 4 of the diff
133 133 $this->checkFeedResults('path-alias', $node); 134 134 } 135 135 136 /** 137 * Tests that rendered node content is in current language. 138 */ 139 public function testFeedTranslation() { changed this line in version 4 of the diff
added 1 commit
added 1 commit
added 1 commit
added 1 commit
added 1 commit
added 1 commit
40 69 * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository 41 70 * The entity display repository. 71 * @param \Drupal\Core\Language\LanguageManagerInterface|null $language_manager 72 * The language manager. 73 * @param \Drupal\Core\Entity\EntityRepositoryInterface|null $entity_repository 74 * The entity repository. 42 75 */ 43 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository) { 76 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository, ?LanguageManagerInterface $language_manager = NULL, ?EntityRepositoryInterface $entity_repository = NULL) { 44 77 parent::__construct($configuration, $plugin_id, $plugin_definition); 45 78 46 79 $this->entityTypeManager = $entity_type_manager; 47 80 $this->entityDisplayRepository = $entity_display_repository; 81 82 if ($language_manager === NULL) { 83 @trigger_error('Passing null as the language_manager service to RssPluginBase::__construct() is deprecated in drupal:10.4.0 and is required from drupal:12.0.0. See https://www.drupal.org/project/drupal/issues/2816447', E_USER_DEPRECATED); The usual way this is expressed is
83 @trigger_error('Passing null as the language_manager service to RssPluginBase::__construct() is deprecated in drupal:10.4.0 and is required from drupal:12.0.0. See https://www.drupal.org/project/drupal/issues/2816447', E_USER_DEPRECATED); 83 @trigger_error('Calling ' . __METHOD__ . ' without the $langugage_manager argument is deprecated in drupal:11.1.0 and it will be required in drupal:12.0.0. See https://www.drupal.org/node/TBA', E_USER_DEPRECATED);
43 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository) { 76 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository, ?LanguageManagerInterface $language_manager = NULL, ?EntityRepositoryInterface $entity_repository = NULL) { 44 77 parent::__construct($configuration, $plugin_id, $plugin_definition); 45 78 46 79 $this->entityTypeManager = $entity_type_manager; 47 80 $this->entityDisplayRepository = $entity_display_repository; 81 82 if ($language_manager === NULL) { 83 @trigger_error('Passing null as the language_manager service to RssPluginBase::__construct() is deprecated in drupal:10.4.0 and is required from drupal:12.0.0. See https://www.drupal.org/project/drupal/issues/2816447', E_USER_DEPRECATED); 84 $language_manager = \Drupal::service('language_manager'); 85 } 86 87 $this->languageManager = $language_manager; 88 89 if ($entity_repository === NULL) { 90 @trigger_error('Passing null as the entity.repository service to RssPluginBase::__construct() is deprecated in drupal:10.4.0 and is required from drupal:12.0.0. See https://www.drupal.org/project/drupal/issues/2816447', E_USER_DEPRECATED); 90 @trigger_error('Passing null as the entity.repository service to RssPluginBase::__construct() is deprecated in drupal:10.4.0 and is required from drupal:12.0.0. See https://www.drupal.org/project/drupal/issues/2816447', E_USER_DEPRECATED); 90 @trigger_error('Calling ' . __METHOD__ . ' without the $entity_repository argment is deprecated in drupal:11.1.0 and it will be required in drupal:12.0.0. See https://www.drupal.org/project/drupal/issues/TBA', E_USER_DEPRECATED)
94 136 95 137 /** 96 138 * Return the main options, which are shown in the summary title. 139 * 140 * @return array 141 * The main options for the summary. 97 142 */ 98 143 public function buildOptionsForm_summary_options() { 99 144 $view_modes = $this->entityDisplayRepository->getViewModes($this->entityTypeId); 100 145 $options = []; 146 94 136 95 137 /** 96 138 * Return the main options, which are shown in the summary title. 139 * 140 * @return array 141 * The main options for the summary. 97 142 */ 98 143 public function buildOptionsForm_summary_options() { 99 144 $view_modes = $this->entityDisplayRepository->getViewModes($this->entityTypeId); 100 145 $options = []; 146 101 147 foreach ($view_modes as $mode => $settings) { 102 148 $options[$mode] = $settings['label']; 103 149 } 150 103 149 } 150 104 151 return $options; 105 152 } 106 153 107 154 /** 108 155 * {@inheritdoc} 109 156 */ 110 public function calculateDependencies() { 157 public function calculateDependencies(): array { 111 158 $dependencies = parent::calculateDependencies(); 112 159 113 $view_mode = $this->entityTypeManager 114 ->getStorage('entity_view_mode') 115 ->load($this->entityTypeId . '.' . $this->options['view_mode']); 160 try { I don't see discussion of these exceptions in the issue. This was added in commit 8ed6f3d2 but there is no reason given.
108 155 * {@inheritdoc} 109 156 */ 110 public function calculateDependencies() { 157 public function calculateDependencies(): array { 111 158 $dependencies = parent::calculateDependencies(); 112 159 113 $view_mode = $this->entityTypeManager 114 ->getStorage('entity_view_mode') 115 ->load($this->entityTypeId . '.' . $this->options['view_mode']); 160 try { 161 $view_mode = $this->entityTypeManager 162 ->getStorage('entity_view_mode') 163 ->load($this->entityTypeId . '.' . $this->options['view_mode']); 164 } 165 catch (InvalidPluginDefinitionException | PluginNotFoundException $e) { 166 \Drupal::logger('views')->error('Could not load entity view mode %view_mode', [ 148 $es_translation->set('body', [['value' => 'Algo en Español']]); 149 $es_translation->save(); 150 151 // Visit the page in english and assert title in English language. 152 $this->drupalGet('rss.xml'); 153 $items = $this->getSession()->getDriver()->find('//channel/item'); 154 foreach ($items as $item) { 155 $title_element = $item->findAll('xpath', 'title'); 156 $this->assertEquals('Something in English', $title_element[0]->getText()); 157 } 158 159 // Visit the page in spanish and assert title in Spanish language. 160 $this->drupalGet('es/rss.xml'); 161 foreach ($items as $item) { 162 $title_element = $item->findAll('xpath', 'title'); 163 $this->assertEquals('Algo en Español', $title_element[0]->getText()); added 508 commits
-
a7df077b...69dc12e1 - 499 commits from branch
project:11.x
- 6c0fb532 - Issue #2816447 by kriboogh: Get feed title in correct language
- cd2450d8 - Issue #2816447 by kriboogh: Get feed title in correct language
- a5faa7a9 - Issue #2816447 by kriboogh: Get feed title in correct language
- 28723654 - Issue #2816447 by kriboogh: Get feed title in correct language
- 4c730bd0 - Issue #2816447 by kriboogh: Get feed title in correct language
- 4927e941 - Issue #2816447 by kriboogh: Get feed title in correct language
- 89743062 - Issue #2816447 by kriboogh: Get feed title in correct language
- 2022862c - Issue #2816447 by kriboogh: Get feed title in correct language
- c1bd0086 - Issue #2816447 by kriboogh: Get feed title in correct language
Toggle commit list-
a7df077b...69dc12e1 - 499 commits from branch
Please register or sign in to reply