|
|
@@ -6,6 +6,7 @@ namespace App\Service\Organization;
|
|
|
use App\Entity\Organization\Organization;
|
|
|
use App\Enum\Organization\OrganizationIdsEnum;
|
|
|
use App\Enum\Organization\SettingsProductEnum;
|
|
|
+use App\Service\Utils\UrlBuilder;
|
|
|
use App\Test\Service\Organization\UtilsTest;
|
|
|
|
|
|
/**
|
|
|
@@ -143,4 +144,49 @@ class Utils
|
|
|
return (int) ($year - 1);
|
|
|
else return (int) $year;
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Return the active subdomain of an organization as a string, or null
|
|
|
+ *
|
|
|
+ * @param Organization $organization
|
|
|
+ * @return string | null
|
|
|
+ */
|
|
|
+ public static function getOrganizationActiveSubdomain(Organization $organization): ?string {
|
|
|
+ foreach ($organization->getParameters()->getSubdomains() as $subdomain) {
|
|
|
+ if ($subdomain->isActive()) {
|
|
|
+ return $subdomain->getSubdomain();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Get the URL of the current website of the organization
|
|
|
+ *
|
|
|
+ * @see https://ressources.opentalent.fr/display/SPEC/Preferences#Preferences-Siteinternet
|
|
|
+ *
|
|
|
+ * @param Organization $organization
|
|
|
+ * @return string | null
|
|
|
+ */
|
|
|
+ public static function getOrganizationWebsite(Organization $organization): ?string {
|
|
|
+ $parameters = $organization->getParameters();
|
|
|
+
|
|
|
+ if ($parameters->getDesactivateOpentalentSiteWeb()) {
|
|
|
+ if ($parameters->getOtherWebsite()) {
|
|
|
+ return UrlBuilder::prependHttps($parameters->getOtherWebsite());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!empty($parameters->getCustomDomain())) {
|
|
|
+ return UrlBuilder::prependHttps($parameters->getCustomDomain());
|
|
|
+ }
|
|
|
+
|
|
|
+ $subdomain = self::getOrganizationActiveSubdomain($organization);
|
|
|
+ if (!$subdomain) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 'https://' . $subdomain . '.opentalent.fr';
|
|
|
+ }
|
|
|
+}
|