forked from fa/breadcrumb-the-shire
30 lines
867 B
PHP
30 lines
867 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace MintyPHP\Module\Bookmarks\Providers;
|
||
|
|
|
||
|
|
use MintyPHP\App\AppContainer;
|
||
|
|
use MintyPHP\App\Module\Contracts\LayoutContextProvider;
|
||
|
|
use MintyPHP\Module\Bookmarks\Support\BookmarkUrlNormalizer;
|
||
|
|
|
||
|
|
final class BookmarksLayoutProvider implements LayoutContextProvider
|
||
|
|
{
|
||
|
|
public function provide(array $session, AppContainer $container): array
|
||
|
|
{
|
||
|
|
$grouped = is_array($session['module.bookmarks.grouped'] ?? null)
|
||
|
|
? $session['module.bookmarks.grouped']
|
||
|
|
: ['groups' => [], 'ungrouped' => []];
|
||
|
|
|
||
|
|
$currentPath = BookmarkUrlNormalizer::canonicalizeRequestUri(
|
||
|
|
(string) ($_SERVER['REQUEST_URI'] ?? ''),
|
||
|
|
localeBase()
|
||
|
|
);
|
||
|
|
|
||
|
|
return [
|
||
|
|
'bookmarks.nav' => [
|
||
|
|
'grouped' => $grouped,
|
||
|
|
'current_path' => $currentPath,
|
||
|
|
],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|