File manager - Edit - /var/www/html/portal/app/Support/PortalBreadcrumb.php
Back
<?php namespace App\Support; use App\Models\Structure; /** * Montagem padronizada de itens para breadcrumb do portal público. */ class PortalBreadcrumb { /** * @return array{label: string, url: string} */ public static function home(): array { return [ 'label' => __('Portal'), 'url' => route('paginas.home'), ]; } /** * @return array{label: string, url: string} */ public static function servicosOnline(): array { return [ 'label' => __('Serviços Online'), 'url' => route('servicos.index'), ]; } /** * @return array{label: string, url: string} */ public static function cartaServicos(): array { return [ 'label' => __('Carta de Serviços'), 'url' => route('servicos.index'), ]; } /** * @return array{label: string, url: string} */ public static function link(string $label, string $url): array { return [ 'label' => $label, 'url' => $url, ]; } /** * @return array{label: string} */ public static function current(string $label): array { return [ 'label' => $label, ]; } /** * Link para secretaria de primeiro nível pelo slug. * * @return array{label: string, url: string} */ public static function secretariaBySlug(string $slug, string $label): array { return self::link($label, url('/secretarias/'.$slug)); } public static function formatOrgLabel(Structure $org): string { $abbreviation = trim((string) ($org->abbreviation ?? '')); if ($abbreviation === '') { return trim((string) $org->name); } return trim((string) $org->name).' ('.$abbreviation.')'; } /** * Links dos órgãos ancestrais (pai), sem o órgão atual. * * @return list<array{label: string, url: string}> */ public static function structureHierarchyLinks(Structure $org): array { $org->loadMissing('pertence'); if (! $org->pertence) { return []; } return [ self::link( self::formatOrgLabel($org->pertence), StructurePublicUrls::detailsUrl($org->pertence) ), ]; } /** * Breadcrumb da página principal do órgão (secretarias/...). * * @return list<array{label: string, url?: string}> */ public static function forOrgHome(Structure $org): array { return array_merge( [self::home()], self::structureHierarchyLinks($org), [self::current(self::formatOrgLabel($org))] ); } /** * Breadcrumb de subpágina vinculada a um órgão. * * @return list<array{label: string, url?: string}> */ public static function forOrgSubpage(Structure $org, string $pageTitle): array { $org->loadMissing('pertence'); $items = array_merge( [self::home()], self::structureHierarchyLinks($org), ); $items[] = self::link( self::formatOrgLabel($org), StructurePublicUrls::detailsUrl($org) ); $items[] = self::current($pageTitle); return $items; } /** * Breadcrumb de páginas HTML em /servicos/{slug}. * * @return list<array{label: string, url?: string}> */ public static function forServicosHtmlPage(Structure $org, string $pageTitle, bool $linkOrgChain): array { $items = [ self::home(), self::servicosOnline(), ]; if ($linkOrgChain) { $items = array_merge($items, self::structureHierarchyLinks($org)); $items[] = self::link( self::formatOrgLabel($org), StructurePublicUrls::detailsUrl($org) ); } $items[] = self::current($pageTitle); return $items; } /** * Breadcrumb padrão da área /servicos (trail intermediário + página atual). * * @param list<array{label: string, url: string}> $trail * @return list<array{label: string, url?: string}> */ public static function forServicosPage(array $trail, string $currentLabel): array { return array_merge( [self::home(), self::servicosOnline()], $trail, [self::current($currentLabel)] ); } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.28 | Generation time: 0.27 |
proxy
|
phpinfo
|
Settings