Skip to content
Snippets Groups Projects

Resolve #3506557 "Provide a follow up"

3 unresolved threads
Files
5
@@ -10,10 +10,12 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ModuleInstallerInterface;
use Drupal\Core\File\FileUrlGeneratorInterface;
use Drupal\Core\Link;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\project_browser\ProjectBrowser\Project;
use Drupal\project_browser\ProjectType;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* An activator for Drupal modules.
@@ -27,6 +29,8 @@ final class ModuleActivator implements InstructionsInterface, TasksInterface {
private readonly ModuleExtensionList $moduleList,
private readonly ModuleHandlerInterface $moduleHandler,
private readonly FileUrlGeneratorInterface $fileUrlGenerator,
private readonly RequestStack $requestStack,
private readonly AccountInterface $currentUser,
) {}
/**
@@ -124,12 +128,25 @@ final class ModuleActivator implements InstructionsInterface, TasksInterface {
if (array_key_exists('configure', $info)) {
$tasks[] = Link::createFromRoute($this->t('Configure'), $info['configure']);
}
if ($this->moduleHandler->moduleExists('help') && $this->moduleHandler->hasImplementations('help', $project->machineName)) {
$tasks[] = Link::createFromRoute($this->t('Help'), 'help.page', [
'name' => $project->machineName,
]);
}
if ($this->currentUser->hasPermission('administer modules')) {
$uninstall_url = Url::fromRoute('project_browser.uninstall')
->setRouteParameter('name', $project->machineName);
$request = $this->requestStack->getCurrentRequest();
if ($request?->query->has('source')) {
$return_to_url = Url::fromRoute('project_browser.browse')
->setRouteParameter('source', $request->query->get('source'))
->toString();
$uninstall_url->setOption('query', ['return_to' => $return_to_url]);
}
$tasks[] = Link::fromTextAndUrl($this->t('Uninstall'), $uninstall_url);
}
return $tasks;
}
Loading