Skip to content
Snippets Groups Projects
Commit 914ae2c8 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3223839 by phenaproxima, spotzero, eric.chenchao: PHP Warning and...

Issue #3223839 by phenaproxima, spotzero, eric.chenchao: PHP Warning and notices caused by contextual links on nodes
parent c45b4619
No related branches found
No related tags found
1 merge request!19Issue #3223839: PHP Warning and notices caused by contextual links on nodes
......@@ -106,6 +106,8 @@ function lightning_core_contextual_links_plugins_alter(array &$contextual_links)
'id' => 'block_content.block_edit_latest_version',
'class' => $class,
'provider' => 'block_content',
'options' => [],
'weight' => 0,
];
}
if ($module_handler->moduleExists('taxonomy')) {
......@@ -114,6 +116,7 @@ function lightning_core_contextual_links_plugins_alter(array &$contextual_links)
'group' => 'taxonomy_term_latest_version',
'route_name' => 'entity.taxonomy_term.edit_form',
'weight' => 10,
'options' => [],
'id' => 'entity.taxonomy_term.latest_version_edit_form',
'class' => $class,
'provider' => 'taxonomy',
......@@ -127,6 +130,8 @@ function lightning_core_contextual_links_plugins_alter(array &$contextual_links)
'id' => 'entity.node.latest_version_edit_form',
'class' => $class,
'provider' => 'node',
'options' => [],
'weight' => 0,
];
}
}
......
<?php
namespace Drupal\Tests\lightning_core\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* @covers lightning_core_contextual_links_plugins_alter
*
* @group lightning_core
*/
class ContextualLinksAlterTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'block_content',
'contextual',
'lightning_core',
'node',
'taxonomy',
];
/**
* Tests that dynamic contextual links are defined correctly.
*/
public function testAlteredContextualLinks(): void {
$links = [
'block_content.block_edit_latest_version',
'entity.taxonomy_term.latest_version_edit_form',
'entity.node.latest_version_edit_form',
];
foreach ($links as $link_id) {
/** @var \Drupal\Core\Menu\ContextualLinkInterface $link */
$link = $this->container->get('plugin.manager.menu.contextual_link')
->createInstance($link_id);
$this->assertNotEmpty($link->getTitle());
$this->assertNotEmpty($link->getRouteName());
$this->assertNotEmpty($link->getGroup());
$this->assertIsArray($link->getOptions());
$this->assertIsInt($link->getWeight());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment