Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions wcfsetup/install/files/acp/templates/__optionRewriteTest.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
'wcf.acp.option.url_omit_index_php.test.status.success': '{jslang}wcf.acp.option.url_omit_index_php.test.status.success{/jslang}'
});

const apps = new Map(Object.entries({
{* this bypasses the route system to force rewritten urls *}
{implode from=$rewriteTestApplications item=$rewriteTestApplication}'{unsafe:$rewriteTestApplication->getPackage()|encodeJS}': '{$__wcf->getPath($rewriteTestApplication->getAbbreviation())}core-rewrite-test/'{/implode}
}));
const apps = new Map(Object.entries(
{unsafe:$rewriteTestApplications|json}
));

AcpUiOptionRewriteTest.init(apps);
});
Expand Down
18 changes: 17 additions & 1 deletion wcfsetup/install/files/lib/acp/form/OptionForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use wcf\data\option\category\OptionCategory;
use wcf\data\option\OptionAction;
use wcf\event\acp\option\RewriteApplicationCollecting;
use wcf\system\application\ApplicationHandler;
use wcf\system\event\EventHandler;
use wcf\system\exception\IllegalLinkException;
use wcf\system\menu\acp\ACPMenu;
use wcf\system\option\OptionHandler;
Expand Down Expand Up @@ -110,10 +112,24 @@ public function assignVariables()
{
parent::assignVariables();

$event = new RewriteApplicationCollecting();
foreach (ApplicationHandler::getInstance()->getApplications() as $application) {
$event->register($application->getPackage()->getName(), WCF::getPath($application->getAbbreviation()));
}

EventHandler::getInstance()->fire($event);
$applications = $event->getApplications();

// Generate a static route to enforce URL rewriting.
$applications = \array_map(
static fn(string $path) => $path . 'core-rewrite-test/',
$applications
);

WCF::getTPL()->assign([
'category' => $this->category,
'optionTree' => $this->optionTree,
'rewriteTestApplications' => ApplicationHandler::getInstance()->getApplications(),
'rewriteTestApplications' => $applications,
]);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

namespace wcf\event\acp\option;

use wcf\event\IPsr14Event;

/**
* Requests the collection additional applications for the rewrite configuration.
*
* @author Alexander Ebert
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class RewriteApplicationCollecting implements IPsr14Event
{
/**
* @var array<string, string>
*/
private array $applications = [];

public function register(string $name, string $path): void
{
$this->applications[$name] = $path;
}

/**
* @return array<string, string>
*/
public function getApplications(): array
{
return $this->applications;
}
}