|
@@ -206,15 +206,19 @@ class OtWebsiteRepository
|
|
|
* file of the given website
|
|
* file of the given website
|
|
|
*
|
|
*
|
|
|
* @param array $website
|
|
* @param array $website
|
|
|
|
|
+ * @param string|null $identifier
|
|
|
* @return Site
|
|
* @return Site
|
|
|
* @throws InvalidWebsiteConfigurationException
|
|
* @throws InvalidWebsiteConfigurationException
|
|
|
|
|
+ * @throws NoSuchRecordException
|
|
|
*/
|
|
*/
|
|
|
- public function generateWebsiteConfiguration(array $website): Site
|
|
|
|
|
|
|
+ public function generateWebsiteConfiguration(array $website, string $identifier = null): Site
|
|
|
{
|
|
{
|
|
|
$rootUid = $this->getWebsiteRootUid($website['uid']);
|
|
$rootUid = $this->getWebsiteRootUid($website['uid']);
|
|
|
|
|
|
|
|
|
|
+ $identifier = $identifier ?? $website['config_identifier'];
|
|
|
|
|
+
|
|
|
return new Site(
|
|
return new Site(
|
|
|
- $website['config_identifier'],
|
|
|
|
|
|
|
+ $identifier,
|
|
|
$rootUid,
|
|
$rootUid,
|
|
|
[
|
|
[
|
|
|
'base' => $this->resolveWebsiteBaseUri($website),
|
|
'base' => $this->resolveWebsiteBaseUri($website),
|
|
@@ -345,6 +349,7 @@ class OtWebsiteRepository
|
|
|
|
|
|
|
|
$tail = $uri->getPath();
|
|
$tail = $uri->getPath();
|
|
|
if ($devMode) {
|
|
if ($devMode) {
|
|
|
|
|
+ $tail = rtrim($tail, '/') . '/';
|
|
|
$tail = preg_replace("/\/?[\w\-]+\/(.*)/", "/$1", $tail);
|
|
$tail = preg_replace("/\/?[\w\-]+\/(.*)/", "/$1", $tail);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -363,11 +368,24 @@ class OtWebsiteRepository
|
|
|
* and parse it.
|
|
* and parse it.
|
|
|
*
|
|
*
|
|
|
* @param int $rootUid
|
|
* @param int $rootUid
|
|
|
|
|
+ * @param string|null $identifier
|
|
|
* @return array Path of the configuration file and parsed configuration of the website
|
|
* @return array Path of the configuration file and parsed configuration of the website
|
|
|
*/
|
|
*/
|
|
|
- public function findConfigFileAndContentFor(int $rootUid): array
|
|
|
|
|
|
|
+ public function findConfigFileAndContentFor(int $rootUid, string $identifier = null): array
|
|
|
{
|
|
{
|
|
|
$configs_directory = $_ENV['TYPO3_PATH_APP'] . "/config/sites/";
|
|
$configs_directory = $_ENV['TYPO3_PATH_APP'] . "/config/sites/";
|
|
|
|
|
+
|
|
|
|
|
+ if ($identifier !== null) {
|
|
|
|
|
+ $filename = $configs_directory . $identifier . "/config.yaml";
|
|
|
|
|
+ $yamlConfig = Yaml::parseFile($filename);
|
|
|
|
|
+
|
|
|
|
|
+ if ($yamlConfig['rootPageId'] === $rootUid) {
|
|
|
|
|
+ return [$filename, $yamlConfig];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new \RuntimeException("No configuration file found for identifier " . $identifier);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$candidates = array_filter(
|
|
$candidates = array_filter(
|
|
|
scandir($configs_directory),
|
|
scandir($configs_directory),
|
|
|
function ($x) { return $x != '.' && $x != '..'; }
|
|
function ($x) { return $x != '.' && $x != '..'; }
|
|
@@ -409,22 +427,24 @@ class OtWebsiteRepository
|
|
|
* Similar to findConfigFileAndContentFor(), but only returns the parsed configuration
|
|
* Similar to findConfigFileAndContentFor(), but only returns the parsed configuration
|
|
|
*
|
|
*
|
|
|
* @param int $rootUid
|
|
* @param int $rootUid
|
|
|
|
|
+ * @param string|null $identifier
|
|
|
* @return array Configuration of the website
|
|
* @return array Configuration of the website
|
|
|
*/
|
|
*/
|
|
|
- public function findConfigFor(int $rootUid): array
|
|
|
|
|
|
|
+ public function findConfigFor(int $rootUid, string $identifier = null): array
|
|
|
{
|
|
{
|
|
|
- $pathAndConfig = $this->findConfigFileAndContentFor($rootUid);
|
|
|
|
|
|
|
+ $pathAndConfig = $this->findConfigFileAndContentFor($rootUid, $identifier);
|
|
|
return $pathAndConfig[1];
|
|
return $pathAndConfig[1];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Similar to findConfigFileAndContentFor(), but only returns the config file path
|
|
* Similar to findConfigFileAndContentFor(), but only returns the config file path
|
|
|
* @param int $rootUid
|
|
* @param int $rootUid
|
|
|
|
|
+ * @param string|null $identifier
|
|
|
* @return string Path of the config file of the given website
|
|
* @return string Path of the config file of the given website
|
|
|
*/
|
|
*/
|
|
|
- public function findConfigFilePathFor(int $rootUid): string
|
|
|
|
|
|
|
+ public function findConfigFilePathFor(int $rootUid, string $identifier = null): string
|
|
|
{
|
|
{
|
|
|
- $pathAndConfig = $this->findConfigFileAndContentFor($rootUid);
|
|
|
|
|
|
|
+ $pathAndConfig = $this->findConfigFileAndContentFor($rootUid, $identifier);
|
|
|
return $pathAndConfig[0];
|
|
return $pathAndConfig[0];
|
|
|
}
|
|
}
|
|
|
|
|
|