forked from fa/breadcrumb-the-shire
41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace MintyPHP\Module\AddressBook\Providers;
|
||
|
|
|
||
|
|
use MintyPHP\App\AppContainer;
|
||
|
|
use MintyPHP\App\Module\Contracts\LayoutContextProvider;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Provides address book data for the layout navigation context.
|
||
|
|
*
|
||
|
|
* Contributes the 'addressBook' key to $layoutNav with URL, active filters,
|
||
|
|
* and people groups from the session.
|
||
|
|
*/
|
||
|
|
final class AddressBookLayoutProvider implements LayoutContextProvider
|
||
|
|
{
|
||
|
|
public function provide(array $session, AppContainer $container): array
|
||
|
|
{
|
||
|
|
// Read query params for active filter state
|
||
|
|
$query = [];
|
||
|
|
try {
|
||
|
|
$query = requestInput()->queryAll();
|
||
|
|
} catch (\Throwable) {
|
||
|
|
// fail-open: may not be available in CLI context
|
||
|
|
}
|
||
|
|
|
||
|
|
return [
|
||
|
|
'addressBook' => [
|
||
|
|
'url' => lurl('address-book'),
|
||
|
|
'activeSearch' => trim((string) ($query['search'] ?? '')),
|
||
|
|
'activeTenants' => appNormalizeStringList($query['tenants'] ?? ''),
|
||
|
|
'activeDepartments' => appNormalizePositiveIntList($query['departments'] ?? ''),
|
||
|
|
'activeRoles' => appNormalizePositiveIntList($query['roles'] ?? ''),
|
||
|
|
'activeCustomFilters' => appNormalizeAddressBookCustomFilterQuery($query),
|
||
|
|
'peopleGroups' => is_array($session['available_departments_by_tenant'] ?? null)
|
||
|
|
? $session['available_departments_by_tenant']
|
||
|
|
: [],
|
||
|
|
],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|