|
|
@@ -65,11 +65,14 @@ class SiteController extends ActionController
|
|
|
"manager" => 3, // Association writer full
|
|
|
];
|
|
|
|
|
|
+ // Creation mode
|
|
|
const MODE_PROD = 1;
|
|
|
const MODE_DEV = 1;
|
|
|
|
|
|
+ // Domain name validation
|
|
|
const RX_DOMAIN = "/([a-z0-9A-Z]\.)*[a-z0-9-]+\.([a-z0-9]{2,24})+(\.co\.([a-z0-9]{2,24})|\.([a-z0-9]{2,24}))*\/?/";
|
|
|
|
|
|
+ // Redirections creation status
|
|
|
const REDIRECTION_UNKNOWN_STATUS = 0;
|
|
|
const REDIRECTION_UPDATED = 1;
|
|
|
const REDIRECTION_CREATED = 2;
|
|
|
@@ -99,19 +102,19 @@ class SiteController extends ActionController
|
|
|
* >> [slug => uid]
|
|
|
* @var array
|
|
|
*/
|
|
|
- private $createdPagesIndex;
|
|
|
+ private array $createdPagesIndex;
|
|
|
|
|
|
/**
|
|
|
* List of the directories created in the process (for rollback purposes)
|
|
|
* @var array
|
|
|
*/
|
|
|
- private $createdDirs;
|
|
|
+ private array $createdDirs;
|
|
|
|
|
|
/**
|
|
|
* List of the files created in the process (for rollback purposes)
|
|
|
* @var array
|
|
|
*/
|
|
|
- private $createdFiles;
|
|
|
+ private array $createdFiles;
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
|
@@ -122,7 +125,7 @@ class SiteController extends ActionController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Return the main informations about the organization's website
|
|
|
+ * Return the SiteInfos object for the organization's website
|
|
|
*
|
|
|
* @param int $organizationId
|
|
|
* @return SiteInfos
|
|
|
@@ -175,8 +178,8 @@ class SiteController extends ActionController
|
|
|
* @return int Uid of the root page of the newly created website
|
|
|
* @throws \RuntimeException|\Exception
|
|
|
*/
|
|
|
- public function createSiteAction(int $organizationId, int $mode=self::MODE_PROD) {
|
|
|
-
|
|
|
+ public function createSiteAction(int $organizationId, int $mode=self::MODE_PROD): int
|
|
|
+ {
|
|
|
$organization = $this->fetchOrganization($organizationId);
|
|
|
|
|
|
// This extra-data can not be retrieved from the API for now, but
|
|
|
@@ -809,6 +812,10 @@ class SiteController extends ActionController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Delete a record from the typo3 db.
|
|
|
+ * If $hard is true, the record is permanently deleted.
|
|
|
+ * Else, it's just marked as deleted.
|
|
|
+ *
|
|
|
* @param string $table
|
|
|
* @param string $whereKey
|
|
|
* @param $whereValue
|
|
|
@@ -830,7 +837,15 @@ class SiteController extends ActionController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * Undo a soft-deletion performed using deleteSiteAction()
|
|
|
+ *
|
|
|
+ * @param int $organizationId
|
|
|
+ * @return int
|
|
|
+ * @throws NoSuchWebsiteException
|
|
|
+ * @throws \Doctrine\DBAL\ConnectionException
|
|
|
+ * @throws \Doctrine\DBAL\DBALException
|
|
|
+ */
|
|
|
public function undeleteSiteAction(int $organizationId) {
|
|
|
$rootUid = $this->findRootUidFor($organizationId);
|
|
|
|
|
|
@@ -1091,7 +1106,7 @@ class SiteController extends ActionController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Get the current status of the organization's website
|
|
|
+ * Get the current status and informations of the organization's website
|
|
|
* If $fullScan is true, a deeper scan will be performed and warnings may be logged
|
|
|
*
|
|
|
* The status is among:
|
|
|
@@ -1328,10 +1343,12 @@ class SiteController extends ActionController
|
|
|
/**
|
|
|
* Retrieve the Organization object from the repository and then,
|
|
|
* from the Opentalent API
|
|
|
+ *
|
|
|
* @param $organizationId
|
|
|
* @return Organization
|
|
|
*/
|
|
|
- private function fetchOrganization($organizationId) {
|
|
|
+ private function fetchOrganization($organizationId): Organization
|
|
|
+ {
|
|
|
$organizationRepository = GeneralUtility::makeInstance(ObjectManager::class)->get(OrganizationRepository::class);
|
|
|
try {
|
|
|
return $organizationRepository->findById($organizationId);
|
|
|
@@ -1348,7 +1365,8 @@ class SiteController extends ActionController
|
|
|
* @return int
|
|
|
* @throws NoSuchWebsiteException
|
|
|
*/
|
|
|
- private function findRootUidFor($organizationId) {
|
|
|
+ private function findRootUidFor($organizationId): int
|
|
|
+ {
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
$queryBuilder->getRestrictions()->removeAll();
|
|
|
$rootUid = $queryBuilder
|
|
|
@@ -1371,8 +1389,8 @@ class SiteController extends ActionController
|
|
|
*
|
|
|
* @return int
|
|
|
*/
|
|
|
- private function getParentFolderUid() {
|
|
|
-
|
|
|
+ private function getParentFolderUid(): int
|
|
|
+ {
|
|
|
$queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages');
|
|
|
$siteCount = $queryBuilder
|
|
|
->count('uid')
|
|
|
@@ -1431,8 +1449,8 @@ class SiteController extends ActionController
|
|
|
string $slug,
|
|
|
string $template = '',
|
|
|
array $moreValues = []
|
|
|
- ) {
|
|
|
-
|
|
|
+ ): int
|
|
|
+ {
|
|
|
$defaultValues = [
|
|
|
'pid' => $pid,
|
|
|
'perms_groupid' => 3,
|
|
|
@@ -1471,7 +1489,8 @@ class SiteController extends ActionController
|
|
|
* @param Organization $organization
|
|
|
* @return int
|
|
|
*/
|
|
|
- private function insertRootPage(Organization $organization) {
|
|
|
+ private function insertRootPage(Organization $organization): int
|
|
|
+ {
|
|
|
return $this->insertPage(
|
|
|
$organization,
|
|
|
$this->getParentFolderUid(),
|
|
|
@@ -1588,7 +1607,8 @@ class SiteController extends ActionController
|
|
|
* @param array $organizationExtraData
|
|
|
* @return string
|
|
|
*/
|
|
|
- private function getTemplateConstants(int $organizationId, array $organizationExtraData) {
|
|
|
+ private function getTemplateConstants(int $organizationId, array $organizationExtraData): string
|
|
|
+ {
|
|
|
return "plugin.tx_ottemplating {\n" .
|
|
|
" settings {\n" .
|
|
|
" organization {\n" .
|
|
|
@@ -1649,7 +1669,8 @@ class SiteController extends ActionController
|
|
|
* @param int $rootUid
|
|
|
* @return array Path of the configuration file and parsed configuration of the website
|
|
|
*/
|
|
|
- protected function findConfigFileAndContentFor(int $organizationId, int $rootUid) {
|
|
|
+ protected function findConfigFileAndContentFor(int $organizationId, int $rootUid): array
|
|
|
+ {
|
|
|
|
|
|
$configs_directory = $_ENV['TYPO3_PATH_APP'] . "/config/sites/";
|
|
|
$candidates = scandir($configs_directory);
|
|
|
@@ -1683,7 +1704,8 @@ class SiteController extends ActionController
|
|
|
* @param int $rootUid
|
|
|
* @return array Configuration of the website
|
|
|
*/
|
|
|
- protected function findConfigFor(int $organizationId, int $rootUid) {
|
|
|
+ protected function findConfigFor(int $organizationId, int $rootUid): array
|
|
|
+ {
|
|
|
$pathAndConfig = $this->findConfigFileAndContentFor($organizationId, $rootUid);
|
|
|
return $pathAndConfig[1];
|
|
|
}
|
|
|
@@ -1694,7 +1716,8 @@ class SiteController extends ActionController
|
|
|
* @param int $rootUid
|
|
|
* @return string Path of the config file of the given website
|
|
|
*/
|
|
|
- protected function findConfigFilePathFor(int $organizationId, int $rootUid) {
|
|
|
+ protected function findConfigFilePathFor(int $organizationId, int $rootUid): string
|
|
|
+ {
|
|
|
$pathAndConfig = $this->findConfigFileAndContentFor($organizationId, $rootUid);
|
|
|
return $pathAndConfig[0];
|
|
|
}
|
|
|
@@ -1795,12 +1818,13 @@ class SiteController extends ActionController
|
|
|
* @param int $rootUid
|
|
|
* @param string $domain
|
|
|
* @param array $userData
|
|
|
- * @return int
|
|
|
+ * @return int The uid of the created be_user
|
|
|
*/
|
|
|
private function createBeUser(int $organizationId,
|
|
|
int $rootUid,
|
|
|
string $domain,
|
|
|
- array $userData) {
|
|
|
+ array $userData): int
|
|
|
+ {
|
|
|
|
|
|
if (!isset($userData['username'])) {
|
|
|
throw new \RuntimeException('Can not find any user with admin access in the Opentalent DB. Abort.');
|