Issue #3099971 by huzooka: Hard-coded uri string in WorkflowListBuilder breaks if Drupal is installed in (webroot) subfolder

(cherry picked from commit 49b03d9954)
merge-requests/64/head
Alex Pott 2020-01-10 16:23:53 +00:00
parent cf2a659a5b
commit 049ddc9d58
No known key found for this signature in database
GPG Key ID: 31905460D4A69276
2 changed files with 13 additions and 1 deletions

View File

@ -7,6 +7,7 @@ use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -93,7 +94,7 @@ class WorkflowListBuilder extends ConfigEntityListBuilder {
$build = parent::render();
$workflow_types_count = count($this->workflowTypeManager->getDefinitions());
if ($workflow_types_count === 0) {
$build['table']['#empty'] = $this->t('There are no workflow types available. In order to create workflows you need to install a module that provides a workflow type. For example, the <a href=":content-moderation">Content Moderation</a> module provides a workflow type that enables workflows for content entities.', [':content-moderation' => '/admin/modules#module-content-moderation']);
$build['table']['#empty'] = $this->t('There are no workflow types available. In order to create workflows you need to install a module that provides a workflow type. For example, the <a href=":content-moderation">Content Moderation</a> module provides a workflow type that enables workflows for content entities.', [':content-moderation' => Url::fromRoute('system.modules_list', [], ['fragment' => 'module-content-moderation'])->toString()]);
}
return $build;
}

View File

@ -2,6 +2,7 @@
namespace Drupal\Tests\workflows\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
/**
@ -46,6 +47,16 @@ class WorkflowUiNoTypeTest extends BrowserTestBase {
$this->assertSession()->linkExists('Content Moderation');
$this->assertSession()->pageTextNotContains('Add workflow');
$this->clickLink('Content Moderation');
$modules_list_url_absolute = Url::fromRoute('system.modules_list', [], [
'fragment' => 'module-content-moderation',
'absolute' => TRUE,
])->toString();
$this->assertSame($this->getSession()->getCurrentUrl(), $modules_list_url_absolute);
// The current user does not have the 'administer modules' permission.
$this->assertSession()->statusCodeEquals(403);
$this->container->get('module_installer')->install(['workflow_type_test']);
// The render cache needs to be cleared because although the cache tags are
// correctly set the render cache does not pick it up.