refactor: rename lib/ to core/ for clearer core-module separation
Rename the top-level lib/ directory to core/ so the project root immediately communicates which code is core platform and which lives in modules/. PHP namespaces (MintyPHP\*) are unchanged — only the Composer PSR-4 path mapping moves from lib/ to core/. Module-internal lib/ directories (modules/*/lib/) are untouched. Updated across the full stack: - composer.json PSR-4 mapping - bootstrap entry points (web/index.php, bin/*, tests/bootstrap.php) - tooling configs (phpstan.neon, phpunit.xml, php-cs-fixer) - 26 architecture contract tests - enforcement-policy, guard-catalog, quality-gates - all documentation (CLAUDE.md, README, 25 docs/, .agents/skills/) - bin/qa-extended.sh search paths - .claude/settings.local.json permission paths Workflow: .agents/runs/CORE-LIB-RENAME-001/ (Analyst → Planner → Executor → Code Review (4 findings fixed) → Security Review → Acceptance Test → Finalizer) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
121
core/Support/Search/SearchItemMapperProvider.php
Normal file
121
core/Support/Search/SearchItemMapperProvider.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Support\Search;
|
||||
|
||||
class SearchItemMapperProvider
|
||||
{
|
||||
public static function mapPreviewItem(string $key, array $data, string $query): ?array
|
||||
{
|
||||
$subtitle = '';
|
||||
|
||||
if ($key === 'users') {
|
||||
$label = trim(($data['first_name'] ?? '') . ' ' . ($data['last_name'] ?? ''));
|
||||
$subtitle = trim((string) ($data['email'] ?? ''));
|
||||
if ($label === '' && $subtitle !== '') {
|
||||
$label = $subtitle;
|
||||
$subtitle = '';
|
||||
}
|
||||
$url = lurl('admin/users/edit/' . ($data['uuid'] ?? '')) . '?search=' . urlencode($query);
|
||||
} elseif ($key === 'permissions') {
|
||||
$label = (string) ($data['description'] ?? '');
|
||||
$url = lurl('admin/permissions/edit/' . ($data['id'] ?? '')) . '?search=' . urlencode($query);
|
||||
} elseif ($key === 'scheduled-jobs') {
|
||||
$jobLabel = trim((string) ($data['label'] ?? ''));
|
||||
$jobKey = trim((string) ($data['job_key'] ?? ''));
|
||||
$status = trim((string) ($data['last_run_status'] ?? ''));
|
||||
$label = $jobLabel !== '' ? $jobLabel : $jobKey;
|
||||
if ($status !== '') {
|
||||
$subtitle = strtoupper($status);
|
||||
}
|
||||
$url = lurl('admin/scheduled-jobs/edit/' . ($data['id'] ?? '')) . '?search=' . urlencode($query);
|
||||
} elseif ($key === 'mail-log') {
|
||||
$toEmail = trim((string) ($data['to_email'] ?? ''));
|
||||
$subject = trim((string) ($data['subject'] ?? ''));
|
||||
$status = trim((string) ($data['status'] ?? ''));
|
||||
$label = $subject !== '' ? $subject : $toEmail;
|
||||
$subtitleParts = [];
|
||||
if ($status !== '') {
|
||||
$subtitleParts[] = strtoupper($status);
|
||||
}
|
||||
if ($toEmail !== '' && $subject !== '') {
|
||||
$subtitleParts[] = $toEmail;
|
||||
}
|
||||
$subtitle = implode(' — ', $subtitleParts);
|
||||
$url = lurl('admin/mail-log/view/' . ($data['id'] ?? '')) . '?search=' . urlencode($query);
|
||||
} elseif ($key === 'pages') {
|
||||
$label = (string) ($data['slug'] ?? '');
|
||||
$url = lurl('page/' . $label) . '?search=' . urlencode($query);
|
||||
} else {
|
||||
$label = (string) ($data['description'] ?? '');
|
||||
$url = lurl('admin/' . $key . '/edit/' . ($data['uuid'] ?? '')) . '?search=' . urlencode($query);
|
||||
}
|
||||
|
||||
if ($label === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$item = ['label' => $label, 'url' => $url];
|
||||
if ($subtitle !== '') {
|
||||
$item['subtitle'] = $subtitle;
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function mapResultItem(string $key, string $label, array $data): ?array
|
||||
{
|
||||
$title = '';
|
||||
$description = '';
|
||||
$url = '';
|
||||
$image = '';
|
||||
|
||||
if ($key === 'users') {
|
||||
$title = trim(($data['first_name'] ?? '') . ' ' . ($data['last_name'] ?? ''));
|
||||
$description = (string) ($data['email'] ?? '');
|
||||
$url = lurl('admin/users/edit/' . ($data['uuid'] ?? ''));
|
||||
} elseif ($key === 'permissions') {
|
||||
$title = (string) ($data['key'] ?? '');
|
||||
$description = (string) ($data['description'] ?? '');
|
||||
$url = lurl('admin/permissions/edit/' . ($data['id'] ?? ''));
|
||||
} elseif ($key === 'scheduled-jobs') {
|
||||
$jobLabel = trim((string) ($data['label'] ?? ''));
|
||||
$jobKey = trim((string) ($data['job_key'] ?? ''));
|
||||
$title = $jobLabel !== '' ? $jobLabel : $jobKey;
|
||||
$status = trim((string) ($data['last_run_status'] ?? ''));
|
||||
$description = $status !== '' ? strtoupper($status) : ($jobKey !== '' ? $jobKey : '');
|
||||
$url = lurl('admin/scheduled-jobs/edit/' . ($data['id'] ?? ''));
|
||||
} elseif ($key === 'pages') {
|
||||
$title = (string) ($data['slug'] ?? '');
|
||||
$description = t('Page');
|
||||
$url = lurl('page/' . $title);
|
||||
} elseif ($key === 'mail-log') {
|
||||
$title = trim((string) ($data['subject'] ?? ''));
|
||||
if ($title === '') {
|
||||
$title = trim((string) ($data['to_email'] ?? ''));
|
||||
}
|
||||
$status = trim((string) ($data['status'] ?? ''));
|
||||
$toEmail = trim((string) ($data['to_email'] ?? ''));
|
||||
$description = trim(($status !== '' ? strtoupper($status) : '') . ($toEmail !== '' ? ' — ' . $toEmail : ''));
|
||||
$url = lurl('admin/mail-log/view/' . ($data['id'] ?? ''));
|
||||
} else {
|
||||
$title = (string) ($data['description'] ?? '');
|
||||
$description = $label;
|
||||
$url = lurl('admin/' . $key . '/edit/' . ($data['uuid'] ?? ''));
|
||||
}
|
||||
|
||||
if ($title === '' || $url === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'type' => $label,
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'url' => $url,
|
||||
'image' => $image,
|
||||
'icon' => SearchUiMetaProvider::iconForKey($key),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user