Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
TYPO3
sg_mail
Commits
43f81b42
Commit
43f81b42
authored
Aug 19, 2020
by
Kevin Ditscheid
Browse files
[TASK] Remove deprecated finishers and add MigrationWizard
parent
5f69cb80
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
232 additions
and
157 deletions
+232
-157
Classes/Updates/MigrateFinishersUpgrade.php
Classes/Updates/MigrateFinishersUpgrade.php
+227
-0
Configuration/Services.yaml
Configuration/Services.yaml
+4
-0
Configuration/Yaml/Forms/FinisherSetupBE.yaml
Configuration/Yaml/Forms/FinisherSetupBE.yaml
+0
-152
Configuration/Yaml/Forms/FinisherSetupFE.yaml
Configuration/Yaml/Forms/FinisherSetupFE.yaml
+0
-5
ext_localconf.php
ext_localconf.php
+1
-0
No files found.
Classes/Updates/MigrateFinishersUpgrade.php
0 → 100644
View file @
43f81b42
<?php
/*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
namespace
SGalinski\SgMail\Updates
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
TYPO3\CMS\Core\Authentication\BackendUserAuthentication
;
use
TYPO3\CMS\Core\Authentication\CommandLineUserAuthentication
;
use
TYPO3\CMS\Core\Core\Environment
;
use
TYPO3\CMS\Core\Localization\LanguageService
;
use
TYPO3\CMS\Core\Utility\GeneralUtility
;
use
TYPO3\CMS\Form\Domain\Configuration\ConfigurationService
;
use
TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager
;
use
TYPO3\CMS\Install\Updates\ChattyInterface
;
use
TYPO3\CMS\Install\Updates\UpgradeWizardInterface
;
/**
* Class MigrateFinishersUpgrade
*
* @package SGalinski\SgMail\Updates
*/
class
MigrateFinishersUpgrade
implements
UpgradeWizardInterface
,
ChattyInterface
{
/**
* THe wizard identifier
*/
const
IDENTIFIER
=
'tx_sgmail_migratefinishers'
;
/**
* @var OutputInterface
*/
protected
$output
;
/**
* @var FormPersistenceManager
*/
protected
$formPersistenceManager
;
/**
* @inheritDoc
*/
public
function
getIdentifier
():
string
{
return
self
::
IDENTIFIER
;
}
/**
* @inheritDoc
*/
public
function
getTitle
():
string
{
return
'Migrates the MailToSenderFinisher and MailToReceiverFinisher'
;
}
/**
* @inheritDoc
*/
public
function
getDescription
():
string
{
return
''
;
}
/**
* @inheritDoc
*/
public
function
executeUpdate
():
bool
{
$this
->
initializeBackendUserAuthentication
();
$this
->
initializeFormPersistenceManager
();
$formData
=
$this
->
loadFormData
();
foreach
(
$formData
as
$persistenceIdentifier
=>
$_formData
)
{
$formChanged
=
FALSE
;
if
((
bool
)
$_formData
[
'readOnly'
])
{
$this
->
output
->
writeln
(
'Form with identifier "'
.
$_formData
[
'identifier'
]
.
'" is readonly!'
);
continue
;
}
if
(
isset
(
$_formData
[
'finishers'
])
&&
is_array
(
$_formData
[
'finishers'
])
)
{
foreach
(
$_formData
[
'finishers'
]
as
&
$finisher
)
{
if
(
$finisher
[
'identifier'
]
===
'MailToSenderFinisher'
||
$finisher
[
'identifier'
]
===
'MailToReceiverFinisher'
)
{
$finisher
=
$this
->
migrateFinisher
(
$finisher
);
$formChanged
=
TRUE
;
}
}
}
if
(
$formChanged
)
{
$this
->
output
->
writeln
(
'Finishers of form with identifier "'
.
$_formData
[
'identifier'
]
.
'" migrated!'
);
$this
->
writeBack
(
$persistenceIdentifier
,
$_formData
);
}
}
return
TRUE
;
}
/**
* @inheritDoc
*/
public
function
updateNecessary
():
bool
{
$this
->
initializeBackendUserAuthentication
();
$this
->
initializeFormPersistenceManager
();
$formData
=
$this
->
loadFormData
();
foreach
(
$formData
as
$_formData
)
{
if
(
isset
(
$_formData
[
'finishers'
])
&&
is_array
(
$_formData
[
'finishers'
]))
{
foreach
(
$_formData
[
'finishers'
]
as
$finisher
)
{
if
(
$finisher
[
'identifier'
]
===
'MailToSenderFinisher'
||
$finisher
[
'identifier'
]
===
'MailToReceiverFinisher'
)
{
return
TRUE
;
}
}
}
}
return
FALSE
;
}
/**
* Migrates the finisher to the new one
*
* @param array $finisher
* @return array
*/
protected
function
migrateFinisher
(
array
$finisher
):
array
{
if
(
$finisher
[
'identifier'
]
===
'MailToSenderFinisher'
)
{
$finisher
[
'identifier'
]
=
'MailToUserFinisher'
;
}
if
(
$finisher
[
'identifier'
]
===
'MailToReceiverFinisher'
)
{
$finisher
[
'identifier'
]
=
'MailToAdminFinisher'
;
}
return
$finisher
;
}
/**
* Load and return the formData of all registered forms
*
* @return array
*/
protected
function
loadFormData
():
array
{
$forms
=
$this
->
formPersistenceManager
->
listForms
();
$formData
=
[];
foreach
(
$forms
as
$form
)
{
if
((
bool
)
$form
[
'invalid'
]
!==
TRUE
)
{
$_formData
=
$this
->
formPersistenceManager
->
load
(
$form
[
'persistenceIdentifier'
]);
if
(
$_formData
[
'invalid'
]
!==
TRUE
)
{
$formData
[
$form
[
'persistenceIdentifier'
]]
=
$_formData
;
}
}
}
return
$formData
;
}
/**
* Write back the form data to the YAML file
*
* @param string $persistenceIdentifier
* @param array $formData
* @throws \TYPO3\CMS\Form\Mvc\Persistence\Exception\PersistenceManagerException
*/
protected
function
writeBack
(
string
$persistenceIdentifier
,
array
$formData
)
{
$this
->
formPersistenceManager
->
save
(
$persistenceIdentifier
,
$formData
);
}
/**
* Initialize the FormPersistenceManager
*/
protected
function
initializeFormPersistenceManager
()
{
$this
->
formPersistenceManager
=
GeneralUtility
::
makeInstance
(
FormPersistenceManager
::
class
);
$this
->
formPersistenceManager
->
initializeObject
();
}
/**
* Initialize a BackendUserAuthentication if none exists
*/
protected
function
initializeBackendUserAuthentication
():
void
{
if
(
!
$GLOBALS
[
'BE_USER'
]
instanceof
BackendUserAuthentication
)
{
if
(
Environment
::
isCli
())
{
$GLOBALS
[
'BE_USER'
]
=
GeneralUtility
::
makeInstance
(
CommandLineUserAuthentication
::
class
);
}
else
{
$GLOBALS
[
'BE_USER'
]
=
GeneralUtility
::
makeInstance
(
BackendUserAuthentication
::
class
);
$GLOBALS
[
'BE_USER'
]
->
start
();
}
$GLOBALS
[
'LANG'
]
=
LanguageService
::
createFromUserPreferences
(
$GLOBALS
[
'BE_USER'
]);
}
}
/**
* @inheritDoc
*/
public
function
getPrerequisites
():
array
{
return
[];
}
/**
* @param OutputInterface $output
*/
public
function
setOutput
(
OutputInterface
$output
):
void
{
$this
->
output
=
$output
;
}
}
Configuration/Services.yaml
View file @
43f81b42
...
...
@@ -18,3 +18,7 @@ services:
SGalinski\SgMail\Domain\Repository\TemplateRepository
:
public
:
true
TYPO3\CMS\Form\Mvc\Persistence\FormPersistenceManager
:
# We need to allow the initialisation via GeneralUtility for our FormFinisher migration wizard
public
:
true
Configuration/Yaml/Forms/FinisherSetupBE.yaml
View file @
43f81b42
...
...
@@ -11,21 +11,6 @@ TYPO3:
10
:
'
EXT:form/Resources/Private/Language/Database.xlf'
20
:
'
EXT:sg_mail/Resources/Private/Language/Database.xlf'
finishersDefinition
:
# TODO deprecated finisher (migration wizard required)
MailToSenderFinisher
:
implementationClassName
:
SGalinski\SgMail\Finisher\Forms\FormsFinisher
formEditor
:
iconIdentifier
:
'
t3-form-icon-finisher'
label
:
'
A
Label
that
seems
to
be
never
used...'
predefinedDefaults
:
options
:
template
:
'
'
mailTo
:
'
'
mailFrom
:
'
'
mailFromName
:
'
'
replyTo
:
'
'
cc
:
'
'
bcc
:
'
'
MailToUserFinisher
:
implementationClassName
:
SGalinski\SgMail\Finisher\Forms\FormsFinisher
formEditor
:
...
...
@@ -40,21 +25,6 @@ TYPO3:
replyTo
:
'
'
cc
:
'
'
bcc
:
'
'
# TODO deprecated finisher (migration wizard required)
MailToReceiverFinisher
:
implementationClassName
:
SGalinski\SgMail\Finisher\Forms\FormsFinisher
formEditor
:
iconIdentifier
:
'
t3-form-icon-finisher'
label
:
'
A
Label
that
seems
to
be
never
used...'
predefinedDefaults
:
options
:
template
:
'
'
mailTo
:
'
'
mailFrom
:
'
'
mailFromName
:
'
'
replyTo
:
'
'
cc
:
'
'
bcc
:
'
'
MailToAdminFinisher
:
implementationClassName
:
SGalinski\SgMail\Finisher\Forms\FormsFinisher
formEditor
:
...
...
@@ -212,128 +182,6 @@ TYPO3:
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
# TODO deprecated (migration wizard required)
45
:
identifier
:
'
MailToSenderFinisher'
editors
:
__inheritances
:
10
:
'
TYPO3.CMS.Form.mixins.formElementMixins.BaseCollectionEditorsMixin'
100
:
label
:
'
formEditor.elements.Form.editor.finishers.mailToUserOld.label'
120
:
identifier
:
'
template'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToUser.editor.template.label'
propertyPath
:
'
options.template'
130
:
identifier
:
'
mailTo'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToUser.editor.mailTo.label'
propertyPath
:
'
options.mailTo'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
NotEmpty'
20
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
140
:
identifier
:
'
mailFrom'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToUser.editor.mailFrom.label'
propertyPath
:
'
options.mailFrom'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
160
:
identifier
:
'
mailFromName'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToUser.editor.mailFromName.label'
propertyPath
:
'
options.mailFromName'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
170
:
identifier
:
'
replyTo'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToUser.editor.replyTo.label'
propertyPath
:
'
options.replyTo'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
180
:
identifier
:
'
cc'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToUser.editor.cc.label'
propertyPath
:
'
options.cc'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
190
:
identifier
:
'
bcc'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToUser.editor.bcc.label'
propertyPath
:
'
options.bcc'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
55
:
identifier
:
'
MailToReceiverFinisher'
editors
:
__inheritances
:
10
:
'
TYPO3.CMS.Form.mixins.formElementMixins.BaseCollectionEditorsMixin'
100
:
label
:
'
formEditor.elements.Form.editor.finishers.mailToAdminOld.label'
120
:
identifier
:
'
template'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToAdmin.editor.template.label'
propertyPath
:
'
options.template'
130
:
identifier
:
'
mailTo'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToAdmin.editor.mailTo.label'
propertyPath
:
'
options.mailTo'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
140
:
identifier
:
'
mailFrom'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToAdmin.editor.mailFrom.label'
propertyPath
:
'
options.mailFrom'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
150
:
identifier
:
'
mailFromName'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToAdmin.editor.mailFromName.label'
propertyPath
:
'
options.mailFromName'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
160
:
identifier
:
'
replyTo'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToAdmin.editor.replyTo.label'
propertyPath
:
'
options.replyTo'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
180
:
identifier
:
'
cc'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToAdmin.editor.cc.label'
propertyPath
:
'
options.cc'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
190
:
identifier
:
'
bcc'
templateName
:
'
Inspector-TextEditor'
label
:
'
formEditor.elements.Form.editor.finishers.mailToAdmin.editor.bcc.label'
propertyPath
:
'
options.bcc'
enableFormelementSelectionButton
:
true
propertyValidators
:
10
:
'
FormElementIdentifierWithinCurlyBracesInclusive'
renderingOptions
:
translation
:
translationFile
:
...
...
Configuration/Yaml/Forms/FinisherSetupFE.yaml
View file @
43f81b42
...
...
@@ -8,8 +8,3 @@ TYPO3:
implementationClassName
:
SGalinski\SgMail\Finisher\Forms\FormsFinisher
MailToAdminFinisher
:
implementationClassName
:
SGalinski\SgMail\Finisher\Forms\FormsFinisher
# TODO deprecated (migration wizard required)
MailToSenderFinisher
:
implementationClassName
:
SGalinski\SgMail\Finisher\Forms\FormsFinisher
MailToReceiverFinisher
:
implementationClassName
:
SGalinski\SgMail\Finisher\Forms\FormsFinisher
ext_localconf.php
View file @
43f81b42
...
...
@@ -31,6 +31,7 @@ call_user_func(
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SC_OPTIONS'
][
'ext/install'
][
'update'
][
\
SGalinski\SgMail\Updates\UpdateLanguages
::
IDENTIFIER
]
=
\
SGalinski\SgMail\Updates\UpdateLanguages
::
class
;
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SC_OPTIONS'
][
'ext/install'
][
'update'
][
\
SGalinski\SgMail\Updates\UpdateGermanAsDefault
::
IDENTIFIER
]
=
\
SGalinski\SgMail\Updates\UpdateGermanAsDefault
::
class
;
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SC_OPTIONS'
][
'ext/install'
][
'update'
][
\
SGalinski\SgMail\Updates\MigrateSchedulerTasks
::
IDENTIFIER
]
=
\
SGalinski\SgMail\Updates\MigrateSchedulerTasks
::
class
;
$GLOBALS
[
'TYPO3_CONF_VARS'
][
'SC_OPTIONS'
][
'ext/install'
][
'update'
][
\
SGalinski\SgMail\Updates\MigrateFinishersUpgrade
::
IDENTIFIER
]
=
\
SGalinski\SgMail\Updates\MigrateFinishersUpgrade
::
class
;
if
(
TYPO3_MODE
===
'BE'
)
{
\
TYPO3\CMS\Core\Utility\ExtensionManagementUtility
::
addTypoScriptSetup
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment