Skip to content
Snippets Groups Projects
Commit 04051f2e authored by catch's avatar catch
Browse files

Issue #2371593 by mikelutz, larowlan, madhavvyas, Mile23, andypost,...

Issue #2371593 by mikelutz, larowlan, madhavvyas, Mile23, andypost, bertramakers, Berdir: Properly deprecate ForumManagerInterface::getParents()
parent 973da437
No related branches found
No related tags found
No related merge requests found
......@@ -154,7 +154,7 @@ public static function create(ContainerInterface $container) {
public function forumPage(TermInterface $taxonomy_term) {
// Get forum details.
$taxonomy_term->forums = $this->forumManager->getChildren($this->config('forum.settings')->get('vocabulary'), $taxonomy_term->id());
$taxonomy_term->parents = $this->forumManager->getParents($taxonomy_term->id());
$taxonomy_term->parents = $this->termStorage->loadAllParents($taxonomy_term->id());
if (empty($taxonomy_term->forum_container->value)) {
$build = $this->forumManager->getTopics($taxonomy_term->id(), $this->currentUser());
......
......@@ -480,6 +480,7 @@ public function resetCache() {
* {@inheritdoc}
*/
public function getParents($tid) {
@trigger_error(__NAMESPACE__ . '\ForumManager::getParents() is deprecated in drupal:8.1.0 and is removed from drupal:9.0.0. Call loadAllParents() on taxonomy term storage directly. See https://www.drupal.org/node/3069599', E_USER_DEPRECATED);
return $this->entityTypeManager->getStorage('taxonomy_term')->loadAllParents($tid);
}
......
......@@ -60,8 +60,10 @@ public function resetCache();
* @return array
* Array of parent terms.
*
* @deprecated Scheduled to be removed in 9.0.x, see
* https://www.drupal.org/node/2371593.
* @deprecated in drupal:8.1.0 and is removed from drupal:9.0.0. Call
* loadAllParents() on taxonomy term storage directly.
*
* @see https://www.drupal.org/node/3069599
*/
public function getParents($tid);
......
<?php
namespace Drupal\Tests\forum\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests Legacy forum code.
*
* @group forum
* @group legacy
*/
class LegacyForumTest extends KernelTestBase {
protected static $modules = [
'comment',
'forum',
'system',
'taxonomy',
'text',
'user',
];
/**
* The taxonomy term storage.
*
* @var \Drupal\taxonomy\TermStorage
*/
protected $termStorage;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('taxonomy_term');
$this->installConfig('forum');
$this->termStorage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
}
/**
* Tests the getParents() method.
*
* @expectedDeprecation Drupal\forum\ForumManager::getParents() is deprecated in drupal:8.1.0 and is removed from drupal:9.0.0. Call loadAllParents() on taxonomy term storage directly. See https://www.drupal.org/node/3069599
*/
public function testGetParents() {
// Add a forum.
$forum = $this->termStorage->create([
'name' => 'Forum',
'vid' => 'forums',
'forum_container' => 1,
]);
$forum->save();
// Add a container.
$subforum = $this->termStorage->create([
'name' => 'Subforum',
'vid' => 'forums',
'forum_container' => 0,
'parent' => $forum->id(),
]);
$subforum->save();
$legacy_parents = \Drupal::service('forum_manager')->getParents($subforum->id());
$parents = $this->termStorage->loadAllParents($subforum->id());
$this->assertSame($parents, $legacy_parents);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment