소스 검색

post refactoring ot_admin fixes

Olivier Massot 4 년 전
부모
커밋
e8b0c8ec9c
1개의 변경된 파일15개의 추가작업 그리고 6개의 파일을 삭제
  1. 15 6
      ot_admin/Classes/Controller/SiteController.php

+ 15 - 6
ot_admin/Classes/Controller/SiteController.php

@@ -1334,7 +1334,6 @@ class SiteController extends ActionController
      * @param string $newDomain
      * @param bool $redirect
      * @return int
-     * @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
      * @throws NoSuchWebsiteException
      * @throws \Opentalent\OtCore\Exception\InvalidWebsiteConfigurationException
      */
@@ -1870,7 +1869,8 @@ class SiteController extends ActionController
      * Insert the root page of a new organization's website
      * and return its uid
      *
-     * @param Organization $organization
+     * @param int $website_uid
+     * @param string $title
      * @return int
      */
     private function insertRootPage(int $website_uid, string $title): int
@@ -1883,9 +1883,7 @@ class SiteController extends ActionController
             self::TEMPLATE_HOME,
             [
                 'is_siteroot' => 1,
-                'TSconfig' => 'TCAdefaults.pages.ot_website_uid=' . $website_uid,
-                'tx_opentalent_template' => self::DEFAULT_THEME,
-                'tx_opentalent_template_preferences' => '{"themeColor":"' . self::DEFAULT_COLOR . '","displayCarousel":"1"}'
+                'TSconfig' => 'TCAdefaults.pages.ot_website_uid=' . $website_uid
             ]
         );
     }
@@ -2046,6 +2044,7 @@ class SiteController extends ActionController
 
     /**
      * Create or update the .../sites/.../config.yaml file of the given site
+     * Return the identifier of the created website
      *
      * @param int $organizationId
      * @param int $rootUid
@@ -2061,7 +2060,8 @@ class SiteController extends ActionController
         $subdomain = explode('.', $domain)[0];
 
         if (!$configFilename) {
-            $configDir = $_ENV['TYPO3_PATH_APP'] . "/config/sites/" . $subdomain . '_' . $organizationId;
+            $identifier = $subdomain . '_' . $organizationId;
+            $configDir = $_ENV['TYPO3_PATH_APP'] . "/config/sites/" . $identifier;
             $configFilename = $configDir . "/config.yaml";
             $isNew = true;
 
@@ -2070,6 +2070,7 @@ class SiteController extends ActionController
             }
         } else {
             $configDir = dirname($configFilename);
+            $identifier = basename($configDir);
             $config['base'] = 'https://' . $domain;
             $isNew = false;
         }
@@ -2115,6 +2116,14 @@ class SiteController extends ActionController
         }
         $this->writeFile($configFilename, $yamlConfig);
 
+        // Update the identifier in the ot_websites table
+        $queryBuilder = $this->connectionPool->getQueryBuilderForTable('ot_websites');
+        $queryBuilder
+            ->update('ot_websites')
+            ->where($queryBuilder->expr()->eq('organization_id', $organizationId))
+            ->set('config_identifier', $identifier)
+            ->execute();
+
         // Set the owner and mods, in case www-data is not the one who run this command
         // @see https://www.php.net/manual/fr/function.stat.php
         try {