You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
<?php
|
|
|
|
namespace App\Console\Commands\Handlers;
|
|
|
|
use App\Console\Commands\Contracts\AttributeScanHandler;
|
|
|
|
class LayoutDataAttributeHandler implements AttributeScanHandler
|
|
{
|
|
public function attributeClass(): string
|
|
{
|
|
return 'LayoutData';
|
|
}
|
|
|
|
public function extractTranslationKeys(array $arguments): array
|
|
{
|
|
$keys = [];
|
|
|
|
// 1. Ambil 'header' jika berupa kunci translasi
|
|
if (isset($arguments['header']) && is_string($arguments['header']) && $this->isTranslationKey($arguments['header'])) {
|
|
$keys[] = $arguments['header'];
|
|
}
|
|
|
|
// 2. Ambil breadcrumbs (hanya KEY/LABEL dari array, abaikan URL/Value)
|
|
if (isset($arguments['breadcrumbs']) && is_array($arguments['breadcrumbs'])) {
|
|
foreach ($arguments['breadcrumbs'] as $labelKey => $url) {
|
|
if (is_string($labelKey) && $this->isTranslationKey($labelKey)) {
|
|
$keys[] = $labelKey;
|
|
}
|
|
}
|
|
}
|
|
|
|
return $keys;
|
|
}
|
|
|
|
private function isTranslationKey(string $value): bool
|
|
{
|
|
return str_contains($value, '/') || str_contains($value, '.');
|
|
}
|
|
}
|
|
|