forked from fa/breadcrumb-the-shire
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:
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Repository\CustomField;
|
||||
|
||||
use MintyPHP\DB;
|
||||
|
||||
/** Manages selected option links for user custom field values (atomic replace). */
|
||||
class UserCustomFieldValueOptionRepository
|
||||
{
|
||||
public static function replaceForValueId(int $valueId, array $optionIds): bool
|
||||
{
|
||||
if ($valueId <= 0) {
|
||||
return false;
|
||||
}
|
||||
$deleted = DB::delete('delete from user_custom_field_value_options where value_id = ?', (string) $valueId);
|
||||
if ($deleted === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$optionIds = array_values(array_unique(array_map('intval', $optionIds)));
|
||||
$optionIds = array_values(array_filter($optionIds, static fn ($id) => $id > 0));
|
||||
if (!$optionIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($optionIds as $optionId) {
|
||||
$inserted = DB::insert(
|
||||
'insert into user_custom_field_value_options (value_id, option_id, created) values (?,?,NOW())',
|
||||
(string) $valueId,
|
||||
(string) $optionId
|
||||
);
|
||||
if ($inserted === false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function listOptionIdsByValueIds(array $valueIds): array
|
||||
{
|
||||
$valueIds = array_values(array_unique(array_map('intval', $valueIds)));
|
||||
$valueIds = array_values(array_filter($valueIds, static fn ($id) => $id > 0));
|
||||
if (!$valueIds) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$rows = DB::select(
|
||||
'select value_id, option_id from user_custom_field_value_options where value_id in (???)',
|
||||
$valueIds
|
||||
);
|
||||
if (!is_array($rows)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$map = [];
|
||||
foreach ($rows as $row) {
|
||||
$data = $row['user_custom_field_value_options'] ?? $row;
|
||||
if (!is_array($data)) {
|
||||
continue;
|
||||
}
|
||||
$valueId = (int) ($data['value_id'] ?? 0);
|
||||
$optionId = (int) ($data['option_id'] ?? 0);
|
||||
if ($valueId <= 0 || $optionId <= 0) {
|
||||
continue;
|
||||
}
|
||||
$map[$valueId] ??= [];
|
||||
$map[$valueId][] = $optionId;
|
||||
}
|
||||
|
||||
foreach ($map as &$ids) {
|
||||
$ids = array_values(array_unique(array_map('intval', $ids)));
|
||||
sort($ids, SORT_NUMERIC);
|
||||
}
|
||||
unset($ids);
|
||||
|
||||
return $map;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user