Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Build/phpstan/Core13/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ parameters:
# @todo recheck rules.
inferPrivatePropertyTypeFromConstructor: true
reportUnmatchedIgnoredErrors: true

typo3:
siteGetAttributeMapping:
dependencies: array|null
2 changes: 1 addition & 1 deletion Classes/Cli/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
use TYPO3\CMS\Core\Mail\MailMessage;
use TYPO3\CMS\Core\Utility\GeneralUtility;

#[AsCommand(name: 'sudhaus7.wizard')]
#[AsCommand(name: 'sudhaus7:wizard')]
final class RunCommand extends Command implements LoggerAwareInterface
{
use LoggerAwareTrait;
Expand Down
12 changes: 8 additions & 4 deletions Classes/CreateProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -1683,10 +1683,10 @@ private function finalUser(): void
*/
private function finalYaml(): void
{
$path = Environment::getProjectPath();
$path = Environment::getConfigPath();
try {
GeneralUtility::mkdir_deep($path . '/config/sites');
} catch (\Exception $e) {
GeneralUtility::mkdir_deep($path . '/sites');
} catch (\Exception) {
}

$event = new GenerateSiteIdentifierEvent($this->siteConfig, $path, $this);
Expand All @@ -1698,7 +1698,7 @@ private function finalYaml(): void
if (empty($identifier)) {
$identifier = Tools::generateSlug($this->getTask()->getShortname());

if (is_dir($path . '/config/sites/' . $identifier)) {
if (is_dir($path . '/sites/' . $identifier)) {
$identifier = Tools::generateSlug($this->getTask()->getLongname() ?? $this->getTask()->getDomainname());
}
}
Expand All @@ -1711,6 +1711,10 @@ private function finalYaml(): void
}
}

if ($this->getTask()->getSiteSets() !== []) {
$this->siteConfig['dependencies'] = $this->getTask()->getSiteSets();
}

$event = new BeforeSiteConfigWriteEvent($this->siteConfig, $this);
$this->eventDispatcher->dispatch($event);
$this->siteConfig = $event->getSiteconfig();
Expand Down
18 changes: 15 additions & 3 deletions Classes/Domain/Model/Creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Creator implements LoggerAwareInterface

/**
* @param array<array-key, mixed> $valuemappingcache
* @param string[] $siteSets
*/
protected function __construct(
protected int $uid,
Expand All @@ -78,7 +79,8 @@ protected function __construct(
protected int $sourcefilemount,
protected string $sourceclass,
protected string $notifyEmail = '',
private array $valuemappingcache = []
private readonly array $siteSets = [],
private array $valuemappingcache = [],
) {}

/**
Expand All @@ -102,7 +104,8 @@ protected function __construct(
* sourceuser: int,
* sourcefilemount: int,
* sourceclass: string,
* notify_email: string
* notify_email: string,
* site_sets?: string
* } $row
*/
public static function createFromDatabaseRow(array $row): Creator
Expand All @@ -127,7 +130,8 @@ public static function createFromDatabaseRow(array $row): Creator
(int)$row['sourceuser'],
(int)$row['sourcefilemount'],
$row['sourceclass'],
$row['notify_email']
$row['notify_email'],
GeneralUtility::trimExplode(',', ($row['site_sets'] ?? ''), true),
);
}

Expand Down Expand Up @@ -396,4 +400,12 @@ public function getNotifyEmail(): string
{
return $this->notifyEmail;
}

/**
* @return string[]
*/
public function getSiteSets(): array
{
return $this->siteSets;
}
}
3 changes: 2 additions & 1 deletion Classes/Services/FolderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public function getOrCreateFromIdentifier(string $identifier, ?ResourceStorageIn
{
$testidentifier = explode(':', $identifier);
if (count($testidentifier) === 2) {
$storage = $this->storageRepository->findByCombinedIdentifier($identifier);
$storage = $this->storageRepository->findByUid((int)$testidentifier[0]);
$identifier = $testidentifier[1];
}

if ($storage === null) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function registerWizardProcess(string $class): void
$GLOBALS['TCA']['tx_sudhaus7wizard_domain_model_creator']['columns']['flexinfo']['config']['ds'][$config->getExtension()] = $config->getFlexinfoFile();
$GLOBALS['TCA']['tx_sudhaus7wizard_domain_model_creator']['types'][$config->getExtension()] = [
'showitem' => '
status,base,sourceclass,sourcepid,projektname,longname,shortname,domainname,contact,email,notify_email,--div--;Benutzer,reduser,redpass,redemail,--div--;Template Konfigurationen,flexinfo,--div--;Log,log,stacktrace
status,base,sourceclass,sourcepid,site_sets,projektname,longname,shortname,domainname,contact,email,notify_email,--div--;Benutzer,reduser,redpass,redemail,--div--;Template Konfigurationen,flexinfo,--div--;Log,log,stacktrace
' . $config->getAddFields(),
];

Expand Down
33 changes: 22 additions & 11 deletions Configuration/TCA/tx_sudhaus7wizard_domain_model_creator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,33 @@
use SUDHAUS7\Sudhaus7Wizard\Backend\TCA\Evaluation\NotifyEmailEvaluation;
use SUDHAUS7\Sudhaus7Wizard\Domain\Model\Creator;
use SUDHAUS7\Sudhaus7Wizard\Sources\LocalDatabase;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

if (!defined('TYPO3')) {
die('Access denied.');
}

return [

'ctrl' => [
'title' => 'LLL:EXT:sudhaus7_wizard/Resources/Private/Language/locallang.xlf:tx_sudhaus7wizard_domain_model_creator',
'title' => 'LLL:EXT:sudhaus7_wizard/Resources/Private/Language/locallang.xlf:tx_sudhaus7wizard_domain_model_creator',
'label' => 'projektname',
'label_alt' => 'status',
'label_alt_force' => true,
'rootLevel' => -1,
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'delete' => 'deleted',
'enablecolumns' => [
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'delete' => 'deleted',
'enablecolumns' => [
'disabled' => 'hidden',
],
'type' => 'base',
'searchFields' => 'projektname,longname,domainname,',
'dynamicConfigFile' => ExtensionManagementUtility::extPath('sudhaus7_wizard') . 'Configuration/TCA/tx_sudhaus7wizard_domain_model_creator.php',
'iconfile' => 'EXT:sudhaus7_wizard/Resources/Public/Icons/icon.svg',
'subtype_value_field' => 'sourceclass',
],
'types' => [
'1' => ['showitem' => 'base'],
],
'palettes' => [
//'1' => Array('showitem' => 'hidden,sys_language_uid,t3ver_label,l10n_parent'),
],
'palettes' => [],
'columns' => [

't3ver_label' => [
Expand Down Expand Up @@ -294,5 +291,19 @@
'renderType' => 'creatorLog',
],
],
// @TODO Wizard should have its own site set collector in order for a template to be able to register only supported optional site sets
'site_sets' => [
'displayCond' => 'FIELD:status:<:' . Creator::STATUS_READY,
'exclude' => true,
'label' => 'LLL:EXT:backend/Resources/Private/Language/locallang_siteconfiguration_tca.xlf:site.dependencies',
'description' => 'LLL:EXT:backend/Resources/Private/Language/siteconfiguration_fieldinformation.xlf:site.dependencies',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'size' => 5,
'itemsProcFunc' => TYPO3\CMS\Core\Site\TcaSiteSetCollector::class . '->populateSiteSets',
'maxitems' => 9999,
],
],
],
];
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ This is a TYPO3 extension with the extension key `sudhaus7_wizard`. With this ex

Changelog

1.0.1
* Feature: Added site set support
* Bugfix: Corrected sites config path for classic installations
* Bugfix: Corrected wizard command
* Bugfix: Ensured correct folder creation

1.0.0
* Requires TYPO3 13.4 (dependency updated from `^13.0` to `^13.4`)
* Requires PHP 8.2 or higher
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: sudhaus7/template
label: Example Site Set
settings:
website:
background:
color: '#386492'
dependencies: []
optionalDependencies:
- typo3/form
10 changes: 5 additions & 5 deletions Tests/Functional/Wizard/Fixtures/Database/template.csv
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ TCEMAIN.permissions {
,3,9,"uploads","Example File Download",1

"tx_sudhaus7wizard_domain_model_creator",
,"uid","pid","title","status","base","projektname","longname","shortname","domainname","contact","reduser","redpass","redemail","sourcepid","flexinfo"
,1,1,"",10,"template","Ready Template","Ready Template","readytemplate","https://wizard.dev/","ready@wizard.de","ready","password","ready@wizard.de","1","<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes"" ?>
,"uid","pid","status","base","projektname","longname","shortname","domainname","contact","reduser","redpass","redemail","sourcepid","flexinfo","site_sets"
,1,1,10,"template","Ready Template","Ready Template","readytemplate","wizard.dev","ready@wizard.de","ready","password","ready@wizard.de","1","<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes"" ?>
<T3FlexForms>
<data>
<sheet index=""sDEF"">
Expand All @@ -37,8 +37,8 @@ TCEMAIN.permissions {
</language>
</sheet>
</data>
</T3FlexForms>"
,2,1,"",5,"template","Not Ready Template","Not Ready Template","notreadytemplate","https://not-wizard.dev/","not-ready@wizard.de","not-ready","password","not-ready@wizard.de","1","<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes"" ?>
</T3FlexForms>","sudhaus7/template"
,2,1,5,"template","Not Ready Template","Not Ready Template","notreadytemplate","https://not-wizard.dev/","not-ready@wizard.de","not-ready","password","not-ready@wizard.de","1","<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes"" ?>
<T3FlexForms>
<data>
<sheet index=""sDEF"">
Expand All @@ -52,7 +52,7 @@ TCEMAIN.permissions {
</language>
</sheet>
</data>
</T3FlexForms>"
</T3FlexForms>",""
"sys_file_storage",
,uid,pid,crdate,deleted,description,name,driver,configuration,is_default,is_browsable,is_public,is_writable,is_online,auto_extract_metadata
,1,0,1675867468,0,"This is the local fileadmin/ directory. This storage mount has been created automatically by TYPO3.","fileadmin","Local","<?xml version=""1.0"" encoding=""utf-8"" standalone=""yes"" ?>
Expand Down
46 changes: 44 additions & 2 deletions Tests/Functional/Wizard/WizardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,32 @@

use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\Attributes\Test;
use SBUERK\TYPO3\Testing\SiteHandling\SiteBasedTestTrait;
use SBUERK\TYPO3\Testing\TestCase\FunctionalTestCase;
use SUDHAUS7\Sudhaus7Wizard\Cli\RunCommand;
use Symfony\Component\Console\Tester\CommandTester;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Core\Site\SiteFinder;

final class WizardTest extends FunctionalTestCase
{
use SiteBasedTestTrait;

protected const LANGUAGE_PRESETS = [
'EN' => [
'id' => 0,
'title' => 'English',
'locale' => 'en_US.UTF8',
],
];

protected array $testExtensionsToLoad = [
'sudhaus7/sudhaus7-wizard',
'sudhaus7/template',
];

protected array $pathsToProvideInTestInstance = [
'typo3conf/ext/sudhaus7_wizard/Tests/Functional/Wizard/Fixtures/Sites/' => 'typo3conf/config/',
'typo3conf/ext/sudhaus7_wizard/Tests/Functional/Wizard/Fixtures/Fileadmin/' => 'fileadmin/',
];

Expand All @@ -34,6 +46,28 @@ protected function setUp(): void
/** @var LanguageServiceFactory $languageServiceFactory */
$languageServiceFactory = $this->get(LanguageServiceFactory::class);
$GLOBALS['LANG'] = $languageServiceFactory->createFromUserPreferences($GLOBALS['BE_USER']);

$this->writeSiteConfiguration(
identifier: 'acme',
site: $this->buildSiteConfiguration(
rootPageId: 1,
base: 'https://localhost/',
websiteTitle: 'ACME',
),
languages: [
$this->buildDefaultLanguageConfiguration('EN', '/'),
],
additional: [
'dependencies' => [
'my-vendor/site-set-identifier',
],
],
);

$this->setUpFrontendRootPage(
pageId: 1,
createSysTemplateRecord: false,
);
}

#[Test]
Expand Down Expand Up @@ -69,5 +103,13 @@ public function wizardGeneratesNewSite(): void

$tester->assertCommandIsSuccessful($tester->getDisplay());
$this->assertCSVDataSet(__DIR__ . '/Fixtures/Results/siteGenerated.csv');

/** @var SiteFinder $siteFinder */
$siteFinder = $this->get(SiteFinder::class);
$site = $siteFinder->getSiteByIdentifier('readytemplate');
self::assertInstanceOf(Site::class, $site);
self::assertEquals('wizard.dev', $site->getBase()->getHost());
self::assertIsArray($site->getAttribute('dependencies'));
self::assertEquals(['sudhaus7/template'], $site->getAttribute('dependencies'));
}
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"phpunit/phpunit": "^11.5",
"saschaegerer/phpstan-typo3": "^3.0",
"sbuerk/fixture-packages": "^1.1",
"sbuerk/typo3-site-based-test-trait": "^2.0 || ^3.0",
"typo3/cms-backend": "^13.4",
"typo3/cms-beuser": "^13.4",
"typo3/cms-frontend": "^13.4",
Expand Down
47 changes: 0 additions & 47 deletions ext_tables.sql
Original file line number Diff line number Diff line change
@@ -1,50 +1,3 @@

CREATE TABLE tx_sudhaus7wizard_domain_model_creator (
uid int(11) NOT NULL auto_increment,
pid int(11) NOT NULL DEFAULT '0',
title varchar(255) NOT NULL DEFAULT '',
category varchar(255) NOT NULL DEFAULT '',
tstamp int(11) unsigned NOT NULL DEFAULT '0',
crdate int(11) unsigned NOT NULL DEFAULT '0',
cruser_id int(11) unsigned NOT NULL DEFAULT '0',
deleted tinyint(4) unsigned NOT NULL DEFAULT '0',
hidden tinyint(4) unsigned NOT NULL DEFAULT '0',
t3_origuid int(11) NOT NULL DEFAULT '0',
sys_language_uid int(11) NOT NULL DEFAULT '0',
l10n_parent int(11) NOT NULL DEFAULT '0',
l10n_diffsource mediumblob,

base varchar(255) NOT NULL DEFAULT '',

projektname text,
longname text,
shortname text,
domainname text,
contact text,

reduser text,
redpass text,
redemail text,

flexinfo text,
email text,
sourceclass varchar(255) NOT NULL DEFAULT '\\SUDHAUS7\\Sudhaus7Wizard\\Sources\\Localdatabase',

valuemapping varchar(255) NOT NULL DEFAULT '',

sourcepid varchar(255) NOT NULL DEFAULT '0',
sourceuser varchar(255) NOT NULL DEFAULT '0',
sourcefilemount varchar(255) NOT NULL DEFAULT '0',

status int(11) unsigned NOT NULL DEFAULT '0',
stacktrace TEXT,
notify_email varchar(255) NOT NULL DEFAULT '',

PRIMARY KEY (uid),
KEY parent (pid),
KEY language (l10n_parent,sys_language_uid)
);

CREATE TABLE tx_sudhaus7wizard_domain_model_log (
creator int(11) NOT NULL DEFAULT '0',
level varchar(16) NOT NULL DEFAULT '',
Expand Down