resolve($domain); if ($ctx->isGlobalRepresentation) { $filters['representation_id'] = $ctx->representationId(); unset($filters['city_id'], $filters['state_id'], $filters['city'], $filters['state']); } return $filters; } public function resolve(?string $hostOrUrl): DomainContext { $domain = Representation::normalizeDomain($hostOrUrl); if ($domain === null) { return DomainContext::empty(); } $city = $this->cityRepo->findByDomain($domain); if ($city !== null) { // دامنه‌ی شهری؛ نماینده‌ای که دامنه‌ی اختصاصی‌اش این باشد وجود ندارد، // ولی ممکن است نماینده‌ای دامنه‌ی شهر را به‌عنوان دامنه‌ی خودش ثبت کرده باشد. $rep = $this->representationRepo->findActiveByDomain($domain); return new DomainContext($rep, $city, false); } // exact ابتدا (production: host = دامنه‌ی واقعی)، سپس fallback اولین-label // (dev: host = `.localhost` باید نماینده‌ی `.ir` را بیابد). $rep = $this->representationRepo->findActiveByDomain($domain) ?? $this->representationRepo->findActiveByDomainPrefix(explode('.', $domain)[0]); if ($rep !== null) { return new DomainContext($rep, null, $rep->isGlobal()); } return DomainContext::empty(); } }