Fix nav sidebar on admin page.

This commit is contained in:
Buster Neece 2022-11-15 19:59:50 -06:00
parent 316eb03a4c
commit dac19b11b7
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
2 changed files with 29 additions and 2 deletions

View File

@ -18,7 +18,7 @@ final class IndexAction
$view = $request->getView();
// Remove the sidebar on the homepage.
$view->addData(['sidebar' => null]);
$view->getSections()->unset('sidebar');
$view = $request->getView();
$viewData = $view->getData();

View File

@ -9,8 +9,10 @@ use LogicException;
/**
* A global section container for templates.
*
* @implements \ArrayAccess<string, string>
*/
final class GlobalSections
final class GlobalSections implements \ArrayAccess
{
private int $sectionMode = Template::SECTION_MODE_REWRITE;
private array $sections = [];
@ -21,11 +23,31 @@ final class GlobalSections
return !empty($this->sections[$section]);
}
public function offsetExists(mixed $offset): bool
{
return $this->has((string)$offset);
}
public function get(string $section, ?string $default = null): ?string
{
return $this->sections[$section] ?? $default;
}
public function offsetGet(mixed $offset): mixed
{
return $this->get((string)$offset);
}
public function unset(string $section): void
{
unset($this->sections[$section]);
}
public function offsetUnset(mixed $offset): void
{
$this->unset((string)$offset);
}
public function set(
string $section,
?string $value,
@ -40,6 +62,11 @@ final class GlobalSections
};
}
public function offsetSet(mixed $offset, mixed $value): void
{
$this->set((string)$offset, (string)$value);
}
public function prepend(string $section, ?string $value): void
{
$this->set($section, $value, Template::SECTION_MODE_PREPEND);