Skip to content

Commit

Permalink
[TASK] Display site setting categories
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Sep 30, 2024
1 parent a42d27e commit 0dd8feb
Show file tree
Hide file tree
Showing 10 changed files with 2,443 additions and 397 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final class SiteSetSettingsDirective extends BaseDirective
{
public const NAME = 'typo3:site-set-settings';
public const FACET = 'Site Setting';
const CATEGORY_FACET = 'Site Setting Category';
public const CATEGORY_FACET = 'Site Setting Category';

public function __construct(
private readonly LoggerInterface $logger,
Expand Down Expand Up @@ -195,18 +195,19 @@ public function buildConfvalMenu(Directive $directive, array $settings, array $c
if ($directive->getOptionString('name') !== '') {
$idPrefix = $directive->getOptionString('name') . '-';
}
$categoryArray= $this->buildCategoryArray($categories, $categoryLabels);
$categoryArray = $this->buildCategoryArray($categories, $categoryLabels);
$rootCategories = [];
foreach ($categoryArray as $key => $category) {
if (isset($categoryArray[$category['parent']])) {
assert(is_array($categoryArray[$category['parent']]['children']));
$categoryArray[$category['parent']]['children'][] = &$categoryArray[$key];
} else {
$rootCategories[] = &$categoryArray[$key];
}
}
foreach ($settings as $key => $setting) {
$confval = $this->buildConfval($setting, $idPrefix, $key, $directive, $labels, $descriptions, $categoryArray);
$this->assignConfvalsToCategories($setting['category']?? '', $categoryArray, $confval, $rootCategories);
$this->assignConfvalsToCategories($setting['category'] ?? '', $categoryArray, $confval, $rootCategories);
}
$confvals = $this->buildCategoryConfvals($rootCategories, $idPrefix, $directive);
$reservedParameterNames = [
Expand Down Expand Up @@ -339,6 +340,8 @@ private function getCategoryRootline(array $categoryArray, string $key): string
}

/**
* @param array<string, array<string, mixed>> $categories
* @param array<string, string> $categoryLabels
* @return array<string, array<string, mixed>>
*/
public function buildCategoryArray(array $categories, array $categoryLabels): array
Expand All @@ -357,12 +360,12 @@ public function buildCategoryArray(array $categories, array $categoryLabels): ar
}

/**
* @param array $categoryArray
* @param array $rootCategories
* @param array<string, array<string, mixed>> $categoryArray
* @param array<array<string, mixed>> $rootCategories
*/
public function assignConfvalsToCategories(string $category, array &$categoryArray, ConfvalNode $confval, array &$rootCategories): void
{
if (isset($categoryArray[$category])) {
if (is_array($categoryArray[$category]['confvals']??false)) {
$categoryArray[$category]['confvals'][] = $confval;
} else {
$categoryArray[$category] = [
Expand All @@ -388,22 +391,25 @@ private function buildCategoryConfvals(array $categories, string $idPrefix, Dire
$confvals = [];
foreach ($categories as $category) {
$children = [];
if (is_array($category['children']??false)) {
if (is_array($category['children'] ?? false)) {
$children = $this->buildCategoryConfvals($category['children'], $idPrefix, $directive);
}
$key = $category['key'];
if ($key === '') {
$key = '_global';
}
assert(is_string($key));
$additionalFields = [];
$additionalFields['searchFacet'] = new InlineCompoundNode([new PlainTextInlineNode(self::CATEGORY_FACET)]);

$label = $category['label'];
if ($label !== '') {
assert(is_string($label));
$additionalFields['Label'] = new InlineCompoundNode([new PlainTextInlineNode($label)]);
}
assert(is_array($category['confvals']));
$confvals[] = new ConfvalNode(
$this->anchorNormalizer->reduceAnchor($idPrefix . $key),
$this->anchorNormalizer->reduceAnchor($idPrefix .'category-'. $key),
$key,
null,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1>Document Title<a class="headerlink" href="#document-title" data-bs-toggle="m
data-homepage="https://typo3.org/"
data-documentation=""
data-issues="https://github.com/TYPO3/testing-framework/issues"
data-source="https://github.com/TYPO3/testing-framework/tree/8.2.1"
data-source="https://github.com/TYPO3/testing-framework/tree/8.2.2"
>
typo3/testing-framework
</a> to test projects based on
Expand Down
Loading

0 comments on commit 0dd8feb

Please sign in to comment.