Issue #2479449 by sudiptadas19, smustgrave, akashkumar07, rithesh bk, rpayanm, pradhumanjain2311, tstoeckler, mrinalini9, tatisilva, larowlan, andypost, dawehner, xjm, yesct: contact_menu_local_tasks_alter() should check whether ['tabs'][0] is set
parent
2319f33906
commit
833e599d18
|
@ -98,7 +98,7 @@ function contact_entity_extra_field_info() {
|
|||
* email address configured.
|
||||
*/
|
||||
function contact_menu_local_tasks_alter(&$data, $route_name) {
|
||||
if ($route_name == 'entity.user.canonical') {
|
||||
if ($route_name == 'entity.user.canonical' && isset($data['tabs'][0])) {
|
||||
foreach ($data['tabs'][0] as $href => $tab_data) {
|
||||
if ($href == 'entity.user.contact_form') {
|
||||
$link_params = $tab_data['#link']['url']->getRouteParameters();
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\Tests\contact\Unit;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @group contact
|
||||
*/
|
||||
class ContactTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Test contact_menu_local_tasks_alter doesn't throw warnings.
|
||||
*/
|
||||
public function testLocalTasksAlter(): void {
|
||||
require_once $this->root . '/core/modules/contact/contact.module';
|
||||
$data = [];
|
||||
\contact_menu_local_tasks_alter($data, 'entity.user.canonical');
|
||||
$this->assertTrue(TRUE, 'No warning thrown');
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue