|
|
@@ -244,6 +244,7 @@ class ShopService
|
|
|
* @param NewStructureArtistPremiumTrialRequest $trialRequest The trial request containing organization data
|
|
|
*
|
|
|
* @return OrganizationCreationRequest The created organization creation request
|
|
|
+ * @throws \Exception
|
|
|
*/
|
|
|
protected function createOrganizationCreationRequestFromTrialRequest(
|
|
|
NewStructureArtistPremiumTrialRequest $trialRequest,
|
|
|
@@ -259,11 +260,7 @@ class ShopService
|
|
|
$organizationCreationRequest->setLegalStatus($trialRequest->getLegalStatus());
|
|
|
$organizationCreationRequest->setSiretNumber($trialRequest->getSiren());
|
|
|
$organizationCreationRequest->setPhoneNumber($trialRequest->getRepresentativePhone());
|
|
|
-
|
|
|
- // Generate a subdomain from the structure name
|
|
|
- // TODO: à améliorer
|
|
|
- $subdomain = $this->generateSubdomain($trialRequest->getStructureName());
|
|
|
- $organizationCreationRequest->setSubdomain($subdomain);
|
|
|
+ $organizationCreationRequest->setSubdomain($trialRequest->getStructureIdentifier());
|
|
|
|
|
|
// Set default values
|
|
|
$organizationCreationRequest->setProduct(SettingsProductEnum::FREEMIUM);
|
|
|
@@ -274,44 +271,4 @@ class ShopService
|
|
|
return $organizationCreationRequest;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Generate a subdomain from a structure name.
|
|
|
- *
|
|
|
- * @param string $name The structure name to generate a subdomain from
|
|
|
- *
|
|
|
- * @return string The generated subdomain
|
|
|
- */
|
|
|
- protected function generateSubdomain(string $name): string
|
|
|
- {
|
|
|
- // Special case for École to ensure it becomes ecole
|
|
|
- $name = str_replace(['É', 'é'], 'e', $name);
|
|
|
-
|
|
|
- // Remove accents and special characters
|
|
|
- if (function_exists('transliterator_transliterate')) {
|
|
|
- $subdomain = transliterator_transliterate('Any-Latin; Latin-ASCII; [^a-zA-Z0-9] > \'-\'; Lower()', $name);
|
|
|
- if ($subdomain === false) {
|
|
|
- // Fallback if transliteration fails
|
|
|
- $subdomain = iconv('UTF-8', 'ASCII//TRANSLIT', $name);
|
|
|
- }
|
|
|
- } else {
|
|
|
- // Fallback if transliterator is not available
|
|
|
- $subdomain = iconv('UTF-8', 'ASCII//TRANSLIT', $name);
|
|
|
- }
|
|
|
-
|
|
|
- // Replace spaces and special characters with hyphens
|
|
|
- $subdomain = preg_replace('/[^a-zA-Z0-9]/', '-', $subdomain);
|
|
|
- // Convert to lowercase
|
|
|
- $subdomain = strtolower($subdomain);
|
|
|
- // Remove consecutive hyphens
|
|
|
- $subdomain = preg_replace('/-+/', '-', $subdomain);
|
|
|
- // Trim hyphens from beginning and end
|
|
|
- $subdomain = trim($subdomain, '-');
|
|
|
- // Limit length
|
|
|
- $subdomain = substr($subdomain, 0, 30);
|
|
|
-
|
|
|
- // Ensure no trailing hyphens after truncation
|
|
|
- $subdomain = rtrim($subdomain, '-');
|
|
|
-
|
|
|
- return $subdomain;
|
|
|
- }
|
|
|
}
|