Commit eca84208 authored by Paul Ilea's avatar Paul Ilea
Browse files

[TASK] Refactor for PHP v 7.0 compatibility

parent c14fbf09
......@@ -43,7 +43,7 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
* Controller for the configuration mode of the backend module
*/
class ConfigurationController extends ActionController {
public const DEFAULT_EXTENSION_KEY = 'sg_mail';
const DEFAULT_EXTENSION_KEY = 'sg_mail';
/**
* DocHeaderComponent
......@@ -66,8 +66,9 @@ class ConfigurationController extends ActionController {
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
public function indexAction($mode = 'new', $selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []
): void {
public function indexAction(
$mode = 'new', $selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []
) {
if ($this->request->hasArgument('message')) {
$this->addFlashMessage($this->request->getArgument('message'), '', FlashMessage::ERROR);
}
......@@ -144,7 +145,7 @@ class ConfigurationController extends ActionController {
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
public function createAction(): void {
public function createAction() {
if (!$this->request->hasArgument('configuration')) {
$this->redirect(
'index', 'Configuration', NULL,
......@@ -212,7 +213,7 @@ class ConfigurationController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public function editAction(): void {
public function editAction() {
if (!$this->request->hasArgument('configuration')) {
$this->redirect(
'index', 'Configuration', NULL,
......@@ -284,7 +285,7 @@ class ConfigurationController extends ActionController {
* @throws UnsupportedRequestTypeException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public function deleteAction(string $selectedTemplate, string $selectedExtension): void {
public function deleteAction(string $selectedTemplate, string $selectedExtension) {
$registerService = $this->objectManager->get(RegisterService::class);
$registerService->deleteTemplate($selectedExtension, $selectedTemplate);
$this->redirect(
......
......@@ -65,7 +65,7 @@ class MailController extends ActionController {
*
* @param TemplateRepository $templateRepository
*/
public function injectTemplateRepository(TemplateRepository $templateRepository): void {
public function injectTemplateRepository(TemplateRepository $templateRepository) {
$this->templateRepository = $templateRepository;
}
......@@ -91,7 +91,7 @@ class MailController extends ActionController {
/**
* @param ViewInterface $view
*/
public function initializeView(ViewInterface $view): void {
public function initializeView(ViewInterface $view) {
parent::initializeView($view);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsInlineCode(
......@@ -117,7 +117,7 @@ class MailController extends ActionController {
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
public function indexAction(array $parameters = []): void {
public function indexAction(array $parameters = []) {
if ($this->request->hasArgument('message')) {
$this->addFlashMessage($this->request->getArgument('message'), '', FlashMessage::INFO);
}
......@@ -319,7 +319,7 @@ class MailController extends ActionController {
* @throws \BadFunctionCallException
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public function sendTestMailAction(array $parameters = []): void {
public function sendTestMailAction(array $parameters = []) {
$arguments = [];
if ($parameters['selectedExtension']) {
$arguments['selectedExtension'] = $parameters['selectedExtension'];
......@@ -399,7 +399,7 @@ class MailController extends ActionController {
/**
* show a notice when no extension is registered
*/
public function emptyAction(): void {
public function emptyAction() {
}
......@@ -412,7 +412,7 @@ class MailController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
public function resetAction($template, $extensionKey): void {
public function resetAction($template, $extensionKey) {
$pid = (int) GeneralUtility::_GP('id');
$this->templateRepository->deleteTemplate($extensionKey, $template, $pid);
......
......@@ -61,7 +61,7 @@ class QueueController extends ActionController {
*
* @param MailRepository $mailRepository
*/
public function injectMailRepository(MailRepository $mailRepository): void {
public function injectMailRepository(MailRepository $mailRepository) {
$this->mailRepository = $mailRepository;
}
......@@ -73,7 +73,7 @@ class QueueController extends ActionController {
/**
* @param ViewInterface $view
*/
public function initializeView(ViewInterface $view): void {
public function initializeView(ViewInterface $view) {
parent::initializeView($view);
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$pageRenderer->addJsInlineCode(
......@@ -98,7 +98,7 @@ class QueueController extends ActionController {
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchArgumentException
*/
public function indexAction($selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []): void {
public function indexAction($selectedTemplate = NULL, $selectedExtension = NULL, array $filters = []) {
$pageUid = (int) GeneralUtility::_GP('id');
if (!($this->session instanceof PhpSession)) {
......@@ -197,7 +197,7 @@ class QueueController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException
*/
public function sendMailAction($uid): void {
public function sendMailAction($uid) {
$mailService = new MailTemplateService();
if ($mailService->sendMailFromQueue($uid)) {
$message = LocalizationUtility::translate('backend.success_mail_queue', 'sg_mail');
......@@ -221,7 +221,7 @@ class QueueController extends ActionController {
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException
* @throws \InvalidArgumentException
*/
public function exportAction(array $filters = []): void {
public function exportAction(array $filters = []) {
$exportString = BackendService::getCsvFromQueue($filters);
header('Content-Type: application/force-download');
......
......@@ -42,7 +42,7 @@ class FormsFinisher extends AbstractFinisher {
*
* @var array
*/
public const IGNORE_FIELDS = [
const IGNORE_FIELDS = [
'Honeypot', 'Hidden'
];
......
......@@ -49,20 +49,20 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
*/
class BackendService {
// options for the queue search filter
public const SENDER_FILTER_OPTION = 0;
public const RECIPIENT_FILTER_OPTION = 1;
public const SUBJECT_FILTER_OPTION = 2;
public const MAILTEXT_FILTER_OPTION = 3;
public const CC_FILTER_OPTION = 4;
public const BCC_FILTER_OPTION = 5;
public const FROM_NAME_FILTER_OPTION = 6;
public const REPLY_TO_NAME_FILTER_OPTION = 7;
const SENDER_FILTER_OPTION = 0;
const RECIPIENT_FILTER_OPTION = 1;
const SUBJECT_FILTER_OPTION = 2;
const MAILTEXT_FILTER_OPTION = 3;
const CC_FILTER_OPTION = 4;
const BCC_FILTER_OPTION = 5;
const FROM_NAME_FILTER_OPTION = 6;
const REPLY_TO_NAME_FILTER_OPTION = 7;
// constants for deetermining the backend mode
public const BACKEND_MODE_EDITOR = 'editor';
public const BACKEND_MODE_EDITOR_CONTROLLER = 'Mail';
public const BACKEND_MODE_QUEUE = 'queue';
public const BACKEND_MODE_QUEUE_CONTROLLER = 'Queue';
const BACKEND_MODE_EDITOR = 'editor';
const BACKEND_MODE_EDITOR_CONTROLLER = 'Mail';
const BACKEND_MODE_QUEUE = 'queue';
const BACKEND_MODE_QUEUE_CONTROLLER = 'Queue';
/**
* Get all pages the be user has access to
......@@ -122,7 +122,7 @@ class BackendService {
* @throws \InvalidArgumentException
* @throws \UnexpectedValueException
*/
public static function makeButtons($docHeaderComponent, $request): void {
public static function makeButtons($docHeaderComponent, $request) {
/** @var ButtonBar $buttonBar */
$buttonBar = $docHeaderComponent->getButtonBar();
......@@ -450,7 +450,7 @@ class BackendService {
$currentSiteBlacklist = GeneralUtility::trimExplode(',', $currentSite, TRUE);
if ((int) $currentSiteBlacklist[0] === $siteRootId) {
foreach ($currentSiteBlacklist as $excludedTemplate) {
[$extensionKey, $templateName] = GeneralUtility::trimExplode('.', $excludedTemplate);
list($extensionKey, $templateName) = GeneralUtility::trimExplode('.', $excludedTemplate);
if ($extensionKey && $templateName && isset($registerArray[$extensionKey][$templateName])) {
unset($registerArray[$extensionKey][$templateName]);
}
......@@ -467,7 +467,7 @@ class BackendService {
',', $extensionConfiguration['excludeTemplatesAllDomains'], TRUE
);
foreach ($excludedTemplates as $excludedTemplate) {
[$extensionKey, $templateName] = GeneralUtility::trimExplode('.', $excludedTemplate);
list($extensionKey, $templateName) = GeneralUtility::trimExplode('.', $excludedTemplate);
if ($extensionKey && $templateName && isset($registerArray[$extensionKey][$templateName])) {
unset($registerArray[$extensionKey][$templateName]);
}
......
......@@ -52,16 +52,16 @@ use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
* MailTemplateService
*/
class MailTemplateService {
public const MARKER_TYPE_STRING = 'String';
public const MARKER_TYPE_ARRAY = 'Array';
public const MARKER_TYPE_OBJECT = 'Object';
public const MARKER_TYPE_FILE = 'File';
public const DEFAULT_LANGUAGE = 'default';
public const DEFAULT_TEMPLATE_PATH = 'Resources/Private/Templates/SgMail/';
public const CACHE_NAME = 'sg_mail_registerArrayCache';
public const CACHE_LIFETIME_IN_SECONDS = 86400;
public const REGISTER_FILE = 'Register.php';
public const CONFIG_PATH = 'Configuration/MailTemplates';
const MARKER_TYPE_STRING = 'String';
const MARKER_TYPE_ARRAY = 'Array';
const MARKER_TYPE_OBJECT = 'Object';
const MARKER_TYPE_FILE = 'File';
const DEFAULT_LANGUAGE = 'default';
const DEFAULT_TEMPLATE_PATH = 'Resources/Private/Templates/SgMail/';
const CACHE_NAME = 'sg_mail_registerArrayCache';
const CACHE_LIFETIME_IN_SECONDS = 86400;
const REGISTER_FILE = 'Register.php';
const CONFIG_PATH = 'Configuration/MailTemplates';
/**
* @var string $toAddresses
......@@ -243,7 +243,7 @@ class MailTemplateService {
/**
* @param string $fromName
*/
public function setFromName($fromName): void {
public function setFromName($fromName) {
$this->fromName = $fromName;
}
......@@ -252,7 +252,7 @@ class MailTemplateService {
*
* @param string $markerType
*/
public static function getReadableMarkerType($markerType): void {
public static function getReadableMarkerType($markerType) {
switch ($markerType) {
case self::MARKER_TYPE_STRING :
LocalizationUtility::translate('backend.marker.type.string', 'sg_mail');
......@@ -516,7 +516,7 @@ class MailTemplateService {
/**
* @param string $subject
*/
public function setSubject(string $subject): void {
public function setSubject(string $subject) {
$this->subject = $subject;
}
......@@ -530,7 +530,7 @@ class MailTemplateService {
/**
* @param string $overwrittenEmailBody
*/
public function setOverwrittenEmailBody(string $overwrittenEmailBody): void {
public function setOverwrittenEmailBody(string $overwrittenEmailBody) {
$this->overwrittenEmailBody = $overwrittenEmailBody;
}
......@@ -897,12 +897,12 @@ class MailTemplateService {
* Send a Mail from the queue, identified by its id
*
* @param int $uid
* @return bool
* @return bool|NULL
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\IllegalObjectTypeException
* @throws \TYPO3\CMS\Extbase\Persistence\Exception\UnknownObjectException
* @throws \Exception
*/
public function sendMailFromQueue($uid): ?bool {
public function sendMailFromQueue($uid): bool {
$mailRepository = $this->objectManager->get(MailRepository::class);
/** @var Mail $mailToSend */
$mailToSend = $mailRepository->findOneByUid($uid);
......@@ -965,7 +965,7 @@ class MailTemplateService {
*
* @param Template $template
*/
private function loadTemplateValues($template): void {
private function loadTemplateValues($template) {
$fromName = \trim($template->getFromName());
if ($fromName === '') {
$fromName = $this->fromName;
......
......@@ -39,10 +39,10 @@ use TYPO3\CMS\Extbase\Object\ObjectManager;
* Provides an api for registering your mail templates
*/
class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
public const CACHE_NAME = 'sg_mail_registerArrayCache';
public const CACHE_LIFETIME_IN_SECONDS = 86400;
public const DEFAULT_TEMPLATE_PATH = 'Resources/Private/Templates/SgMail/';
public const CONFIG_PATH = 'Configuration/MailTemplates/Forms';
const CACHE_NAME = 'sg_mail_registerArrayCache';
const CACHE_LIFETIME_IN_SECONDS = 86400;
const DEFAULT_TEMPLATE_PATH = 'Resources/Private/Templates/SgMail/';
const CONFIG_PATH = 'Configuration/MailTemplates/Forms';
/**
* contains the actual registration data
......@@ -159,7 +159,7 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
*/
private function writeRegisterArrayEntry(
$extensionKey, $templateKey, array $configArray
): void {
) {
// template_path means where to find the mail body content (usually it's set directly in the registration
// as template_content)
$templatePath = '';
......@@ -215,7 +215,7 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
*
* @throws \TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException
*/
public function clearCaches(): void {
public function clearCaches() {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$cacheManager = $objectManager->get(CacheManager::class);
......@@ -278,7 +278,7 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
*
* @param string $templateKey
*/
public function deleteRegisterFile($templateKey): void {
public function deleteRegisterFile($templateKey) {
$configurationLocation = $this->getRegistrationPath();
$registerFolder = GeneralUtility::getFileAbsFileName($configurationLocation);
GeneralUtility::mkdir_deep($registerFolder);
......@@ -306,7 +306,7 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
* Register the caches for the RegisterService
* This method is for usage in ext_localconf.php to register the cache configuration
*/
public function registerCache(): void {
public function registerCache() {
$cacheConfigurations = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
if (!isset($cacheConfigurations[self::CACHE_NAME])) {
$cacheConfigurations[self::CACHE_NAME] = [
......@@ -406,7 +406,7 @@ class RegisterService implements \TYPO3\CMS\Core\SingletonInterface {
public function migrateTemplateEntries(
string $oldTemplateName, string $oldExtensionKey,
string $newTemplateName, string $newExtensionKey
): void {
) {
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'tx_sgmail_domain_model_template'
);
......
......@@ -49,7 +49,7 @@ class PhpSession implements SingletonInterface {
* @param string $sessionKey
* @return void
*/
public function setSessionKey($sessionKey): void {
public function setSessionKey($sessionKey) {
$this->sessionKey = $sessionKey;
}
......@@ -68,7 +68,7 @@ class PhpSession implements SingletonInterface {
* @param mixed $data
* @return void
*/
public function exchangeData($data): void {
public function exchangeData($data) {
$this->destroy();
$_SESSION[$this->sessionKey] = $data;
}
......@@ -89,7 +89,7 @@ class PhpSession implements SingletonInterface {
* @param mixed $data
* @return void
*/
public function setDataByKey($key, $data): void {
public function setDataByKey($key, $data) {
$_SESSION[$this->sessionKey][$key] = $data;
}
......@@ -109,7 +109,7 @@ class PhpSession implements SingletonInterface {
* @param string $key
* @return void
*/
public function unsetDataByKey($key): void {
public function unsetDataByKey($key) {
unset($_SESSION[$this->sessionKey][$key]);
}
......@@ -118,7 +118,7 @@ class PhpSession implements SingletonInterface {
*
* @return void
*/
public function destroy(): void {
public function destroy() {
unset($_SESSION[$this->sessionKey]);
}
}
......@@ -176,13 +176,17 @@ class FormEditorController extends \TYPO3\CMS\Form\Controller\FormEditorControll
*/
private static function getFormFieldsRecursive($formData = []) {
$out = [];
$renderables = [];
foreach ($formData as $formElement) {
if (isset($formElement['renderables'])) {
$out = \array_merge($out, self::getFormFieldsRecursive($formElement['renderables']));
$renderables[] = self::getFormFieldsRecursive($formElement['renderables']);
} elseif (!\in_array($formElement['type'], self::IGNORE_FIELDS, TRUE)) {
$out[] = $formElement;
}
}
if (count($renderables)) {
$out = \array_merge($out, ...$renderables);
}
return $out;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment