Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Remove createSitePackage action #5139

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,9 @@ public function updateSiteAction(Site $site, $newSiteNodeName)
}

/**
* Create a new site form.
*
* @param Site $site Site to create
* @Flow\IgnoreValidation("$site")
* @return void
* Create a new site form
*/
public function newSiteAction(Site $site = null)
public function newSiteAction(): void
{
// This is not 100% correct, but it is as good as we can get it to work right now
try {
Expand All @@ -259,88 +255,12 @@ public function newSiteAction(Site $site = null)

$sitePackages = $this->packageManager->getFilteredPackages('available', 'neos-site');

$generatorServiceIsAvailable = $this->packageManager->isPackageAvailable('Neos.SiteKickstarter');
$generatorServices = [];

if ($generatorServiceIsAvailable) {
/** @var SiteGeneratorCollectingService $siteGeneratorCollectingService */
$siteGeneratorCollectingService = $this->objectManager->get(SiteGeneratorCollectingService::class);
/** @var SitePackageGeneratorNameService $sitePackageGeneratorNameService */
$sitePackageGeneratorNameService = $this->objectManager->get(SitePackageGeneratorNameService::class);

$generatorClasses = $siteGeneratorCollectingService->getAllGenerators();

foreach ($generatorClasses as $generatorClass) {
$name = $sitePackageGeneratorNameService->getNameOfSitePackageGenerator($generatorClass);
$generatorServices[$generatorClass] = $name;
}
}

$this->view->assignMultiple([
'sitePackages' => $sitePackages,
'documentNodeTypes' => $documentNodeTypes,
'site' => $site,
'generatorServiceIsAvailable' => $generatorServiceIsAvailable,
'generatorServices' => $generatorServices
'documentNodeTypes' => $documentNodeTypes
]);
}

/**
* Create a new site-package and directly import it.
*
* @param string $packageKey Package Name to create
* @param string $generatorClass Generator Class to generate the site package
* @param string $siteName Site Name to create
* @Flow\Validate(argumentName="$packageKey", type="\Neos\Neos\Validation\Validator\PackageKeyValidator")
* @return void
*/
public function createSitePackageAction(string $packageKey, string $generatorClass, string $siteName): void
{
if ($this->packageManager->isPackageAvailable('Neos.SiteKickstarter') === false) {
$this->addFlashMessage(
$this->getModuleLabel('sites.missingPackage.body', ['Neos.SiteKickstarter']),
$this->getModuleLabel('sites.missingPackage.title'),
Message::SEVERITY_ERROR,
[],
1475736232
);
$this->redirect('index');
}

if ($this->packageManager->isPackageAvailable($packageKey)) {
$this->addFlashMessage(
$this->getModuleLabel('sites.invalidPackageKey.body', [htmlspecialchars($packageKey)]),
$this->getModuleLabel('sites.invalidPackageKey.title'),
Message::SEVERITY_ERROR,
[],
1412372021
);
$this->redirect('index');
}
// this should never happen, but if somebody posts unexpected data to the form,
// it should stop here and return some readable error message
if ($this->objectManager->has($generatorClass) === false) {
$this->addFlashMessage(
'The generator class "%s" is not present.',
'Missing generator class',
Message::SEVERITY_ERROR,
[$generatorClass]
);
$this->redirect('index');
}

/** @var SitePackageGeneratorInterface $generatorService */
$generatorService = $this->objectManager->get($generatorClass);
$generatorService->generateSitePackage($packageKey, $siteName);

$this->controllerContext->getFlashMessageContainer()->addMessage(new Message(sprintf(
$this->getModuleLabel('sites.sitePackagesWasCreated.body', [htmlspecialchars($packageKey)]),
'',
null
)));
$this->forward('importSite', null, null, ['packageKey' => $packageKey]);
}

/**
* Import a site from site package.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,40 +59,6 @@ <h2>{neos:backend.translate(id: 'sites.new', value: 'New site', source: 'Modules
</f:if>
</fieldset>
</f:form>

<f:form action="createSitePackage">
<fieldset class="neos-span3 neos-offset1">
<legend>{neos:backend.translate(id: 'sites.createPackage', value: 'Create a new site-package', source: 'Modules')}</legend>
<f:if condition="{generatorServiceIsAvailable}">
<f:then>
<div class="neos-control-group{f:validation.ifHasErrors(for: 'packageKey', then: ' neos-error')}">
<label class="neos-control-label" for="package-key">{neos:backend.translate(id: 'packageKey', value: 'Package key', source: 'Modules')}</label>
<div class="neos-controls">
<f:form.textfield name="packageKey" value="{packageKey}" id="package-key" class="neos-span12" placeholder="{neos:backend.translate(id: 'sites.validPackageKeyInfo', value: 'VendorName.MyPackageKey')}" />
<f:render partial="Module/Shared/FieldValidationResults" arguments="{fieldname: 'packageKey'}"/>
</div>
</div>
<div class="neos-control-group{f:validation.ifHasErrors(for: 'siteName', then: ' neos-error')}">
<label class="neos-control-label" for="site-name">{neos:backend.translate(id: 'sites.name', value: 'Site name', source: 'Modules')}</label>
<div class="neos-controls">
<f:form.textfield name="siteName" value="{siteName}" id="site-name" />
<f:render partial="Module/Shared/FieldValidationResults" arguments="{fieldname: 'siteName'}"/>
</div>
</div>
<div class="neos-control-group{f:validation.ifHasErrors(for: 'generatorClass', then: ' neos-error')}">
<label class="neos-control-label" for="node-type">{neos:backend.translate(id: 'sites.generatorClass', value: 'Select a site generator', source: 'Modules')}</label>
<div class="neos-controls neos-select">
<f:form.select name="generatorClass" options="{generatorServices}" id="generator-class" class="neos-span12" />
</div>
</div>
<f:form.submit value="{neos:backend.translate(id: 'sites.createPackage', value: 'Create Site-Package', source: 'Modules')}" class="neos-button neos-button-primary" />
</f:then>
<f:else>
<p>{neos:backend.translate(id: 'sites.noNeosKickstarterInfo', value: 'The <em>Neos Kickstarter</em> package is not installed, install it to kickstart new sites.', source: 'Modules') -> f:format.raw()}</p>
</f:else>
</f:if>
</fieldset>
</f:form>
</div>
<div class="neos-footer">
<f:link.action action="index" class="neos-button">{neos:backend.translate(id: 'cancel', value: 'Cancel')}</f:link.action>
Expand Down
27 changes: 0 additions & 27 deletions Neos.Neos/Resources/Private/Translations/en/Modules.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -374,27 +374,15 @@
<trans-unit id="sites.documentType" xml:space="preserve">
<source>Select a document nodeType</source>
</trans-unit>
<trans-unit id="sites.generatorClass" xml:space="preserve">
<source>Select a site generator</source>
</trans-unit>
<trans-unit id="sites.name" xml:space="preserve">
<source>Site name</source>
</trans-unit>
<trans-unit id="sites.createNode" xml:space="preserve">
<source>Create empty site</source>
</trans-unit>
<trans-unit id="sites.createPackage" xml:space="preserve">
<source>Create a new site package</source>
</trans-unit>
<trans-unit id="sites.validPackageKeyInfo" xml:space="preserve">
<source>VendorName.MyPackageKey</source>
</trans-unit>
<trans-unit id="sites.noSitesAvailable" xml:space="preserve">
<source>No sites available</source>
</trans-unit>
<trans-unit id="sites.noNeosKickstarterInfo" xml:space="preserve">
<source>The &lt;em&gt;Neos Kickstarter&lt;/em&gt; package is not installed, install it to kickstart new sites.</source>
</trans-unit>
<trans-unit id="sites.new" xml:space="preserve">
<source>New site</source>
</trans-unit>
Expand Down Expand Up @@ -553,21 +541,6 @@ Click on one of the nodes to only see its fallbacks and variants. Click again to
<trans-unit id="sites.update.body" xml:space="preserve">
<source>The site "{0}" has been updated.</source>
</trans-unit>
<trans-unit id="sites.missingPackage.title" xml:space="preserve">
<source>Missing Package</source>
</trans-unit>
<trans-unit id="sites.missingPackage.body" xml:space="preserve">
<source>The package "{0}" is required to create new site packages.</source>
</trans-unit>
<trans-unit id="sites.invalidPackageKey.title" xml:space="preserve">
<source>Invalid package key</source>
</trans-unit>
<trans-unit id="sites.invalidPackageKey.body" xml:space="preserve">
<source>The package key "{0}" already exists.</source>
</trans-unit>
<trans-unit id="sites.sitePackagesWasCreated.body" xml:space="preserve">
<source>Site package {0} was created.</source>
</trans-unit>
<trans-unit id="sites.theSiteHasBeenImported.body" xml:space="preserve">
<source>The site has been imported.</source>
</trans-unit>
Expand Down
Loading