From 57a4e34eb9e12c3a17e754745959c7ea4f8431f3 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Wed, 22 Sep 2021 13:15:20 +0200 Subject: [PATCH 01/10] [TASK] Cleanup configuration handling --- Classes/Controller/ActionController.php | 8 +++-- Classes/Traits/DependencyInjectionTrait.php | 39 ++------------------- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/Classes/Controller/ActionController.php b/Classes/Controller/ActionController.php index 3ecafa6..ed5070d 100644 --- a/Classes/Controller/ActionController.php +++ b/Classes/Controller/ActionController.php @@ -204,9 +204,11 @@ class ActionController extends BaseController */ public function initializeAction() { - $this->config = GeneralUtility::removeDotsFromTS( - $GLOBALS['TSFE']->config['config'] - ); + if ($GLOBALS['TSFE']->config['config']) { + $this->config = GeneralUtility::removeDotsFromTS( + $GLOBALS['TSFE']->config['config'] + ); + } $this->pageType = GeneralUtility::_GP('type'); if (!is_numeric($this->pageType)) { $this->pageType = 0; diff --git a/Classes/Traits/DependencyInjectionTrait.php b/Classes/Traits/DependencyInjectionTrait.php index a9ad822..27dbbc8 100644 --- a/Classes/Traits/DependencyInjectionTrait.php +++ b/Classes/Traits/DependencyInjectionTrait.php @@ -19,18 +19,12 @@ use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Reflection\ClassSchema; use TYPO3\CMS\Extbase\Reflection\ReflectionService; -use TYPO3\CMS\Frontend\Utility\EidUtility; /** * ValidationTrait */ trait DependencyInjectionTrait { - /* - * extension Key - */ - protected $extensionKey = null; - /* * storagePids */ @@ -86,13 +80,9 @@ trait DependencyInjectionTrait $this->objectManager = GeneralUtility::makeInstance( ObjectManager::class ); - $this->initFrontendController(); $this->configurationManager = $this->objectManager->get( ConfigurationManagerInterface::class ); - $this->configurationManager->setConfiguration( - array() - ); $this->apiUtility = $this->objectManager->get( ApiUtility::class ); @@ -100,7 +90,9 @@ trait DependencyInjectionTrait ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $this->getExtensionKey() ); - $this->configurationManager->setConfiguration($frameworkConfiguration); + $this->configurationManager->setConfiguration( + $frameworkConfiguration + ); $this->settings = $frameworkConfiguration; $this->storagePids = explode( ',', @@ -126,29 +118,4 @@ trait DependencyInjectionTrait } } - /** - * Initialize frontentController - * - * @return void - */ - private function initFrontendController() - { - $currentDomain = strtok(GeneralUtility::getIndpEnv('HTTP_HOST'), ':'); - $frontendController = GeneralUtility::makeInstance( - \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, - $GLOBALS['TYPO3_CONF_VARS'], - null, - 0, - true - ); - $GLOBALS['TSFE'] = $frontendController; - $frontendController->connectToDB(); - $frontendController->fe_user = EidUtility::initFeUser(); - $frontendController->id = $result[0]['pid']; - $frontendController->determineId(); - $frontendController->initTemplate(); - $frontendController->getConfigArray(); - EidUtility::initTCA(); - } - } From 0c534753d890d3cd555af7a04d6a21b1c5c829a1 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Wed, 22 Sep 2021 13:15:55 +0200 Subject: [PATCH 02/10] [TASK] Make function filereferenceToApi public --- Classes/Utility/ApiUtility.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Classes/Utility/ApiUtility.php b/Classes/Utility/ApiUtility.php index f36dd0e..5f75905 100644 --- a/Classes/Utility/ApiUtility.php +++ b/Classes/Utility/ApiUtility.php @@ -213,7 +213,13 @@ class ApiUtility return $result; } - private function filereferenceToApi($object) { + public function filereferenceToApi($object) { + $this->objectManager = GeneralUtility::makeInstance( + ObjectManager::class + ); + $this->imageService = $this->objectManager->get( + imageService::class + ); $httpHost = GeneralUtility::getIndpEnv('HTTP_HOST'); $requestHost = GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST'); $publicUrl = $object->getPublicUrl(); From 46f7b519b7c9aae7ff139ccdcd43fd4908270878 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Tue, 26 Oct 2021 23:48:57 +0200 Subject: [PATCH 03/10] [FEATURE] Add persistenceManagerTrait --- Classes/Traits/PersistenceManagerTrait.php | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Classes/Traits/PersistenceManagerTrait.php diff --git a/Classes/Traits/PersistenceManagerTrait.php b/Classes/Traits/PersistenceManagerTrait.php new file mode 100644 index 0000000..0ad1e0c --- /dev/null +++ b/Classes/Traits/PersistenceManagerTrait.php @@ -0,0 +1,37 @@ + + * + ***/ + +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper; +use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; + +/** + * ValidationTrait + */ +trait PersistenceManagerTrait +{ + + /** + * + */ + public function persistAll() + { + (GeneralUtility::makeInstance( + ObjectManager::class + )->get( + PersistenceManager::class + ))->persistAll(); + } +} From f206c8fb0e8cc79ed79fc53e82cf6ab4bb2e6b72 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Tue, 26 Oct 2021 23:50:04 +0200 Subject: [PATCH 04/10] [TASK] Improve ajax and mail sending handling --- Classes/Controller/ActionController.php | 35 +++- Classes/Utility/MailUtility.php | 72 +++++++- .../Private/Partials/Mails/DefaultHtml.html | 154 +++++++++++++++++- .../Private/Partials/Mails/DefaultText.html | 50 ++++++ 4 files changed, 293 insertions(+), 18 deletions(-) create mode 100644 Resources/Private/Partials/Mails/DefaultText.html diff --git a/Classes/Controller/ActionController.php b/Classes/Controller/ActionController.php index ed5070d..918e378 100644 --- a/Classes/Controller/ActionController.php +++ b/Classes/Controller/ActionController.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; use TYPO3\CMS\Extbase\Property\PropertyMapper; use TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationBuilder; +use TYPO3\CMS\Extbase\Service\EnvironmentService; use TYPO3\CMS\Extbase\Service\ExtensionService; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; @@ -148,6 +149,22 @@ class ActionController extends BaseController $this->extensionService = $extensionService; } + /** + * environmentService + * + * @var EnvironmentService + */ + protected $environmentService; + + /** + * @param + */ + public function injectEnvironmentService( + EnvironmentService $environmentService + ) { + $this->environmentService = $environmentService; + } + /** * propertyMapper * @@ -253,7 +270,7 @@ class ActionController extends BaseController } /** - * returns an instance of uribuilder + * */ public function persistAll() { @@ -596,11 +613,14 @@ class ActionController extends BaseController ->setCreateAbsoluteUri(true) ->setAddQueryString(true) ->setTargetPageType($this->ajaxPageType) - ->setArguments(['cid' => $this->contentObjectUid]) + ->setArguments([ + 'cid' => $this->contentObjectUid, + 'type' => $this->ajaxPageType, + ]) ->uriFor($this->request->getControllerActionName()); $this->ajaxEnv = [ - 'uri' => $uri, - 'object' => $object, + 'uri' => $uri, + 'object' => $object, 'namespace' => $this->getPluginNamespace(), ]; } @@ -744,7 +764,11 @@ class ActionController extends BaseController $this->response->setStatus($this->responseStatus); } if ($this->pageType == $this->ajaxPageType) { - $GLOBALS['TSFE']->setContentType('application/json'); + if ($this->environmentService->isEnvironmentInBackendMode()) { + header('Content-Type: application/json'); + } else { + $GLOBALS['TSFE']->setContentType('application/json'); + } } unset($result['data']); if ($this->redirect) { @@ -769,5 +793,4 @@ class ActionController extends BaseController } $this->view->assignMultiple($result); } - } diff --git a/Classes/Utility/MailUtility.php b/Classes/Utility/MailUtility.php index 19129ce..6f16ebe 100644 --- a/Classes/Utility/MailUtility.php +++ b/Classes/Utility/MailUtility.php @@ -36,9 +36,10 @@ class MailUtility */ public static function parseContentTemplate( $text, - $markers = [] + $markers = [], + $lineEnd = "\r\n" ) { - $textParts = explode("\r\n\r\n", $text); + $textParts = explode($lineEnd . $lineEnd, $text); $result = []; foreach ($textParts as $textPart) { $type = 'text'; @@ -54,6 +55,22 @@ class MailUtility $type = 'headline3'; $textPart = substr($textPart, 4); } + if (substr($textPart, 0, 2) === '- ') { + $type = 'list'; + $textPart = substr($textPart, 2); + } + if (substr($textPart, 0, 2) === '| ') { + $type = 'table'; + $textPart = substr($textPart, 2); + } + if (substr($textPart, 0, 3) === '|| ') { + $type = 'tableLayout'; + $textPart = substr($textPart, 3); + } + if (substr($textPart, 0, 9) === '%subject ') { + $type = 'subject'; + $textPart = substr($textPart, 9); + } foreach ($markers as $markerName => $markerContent) { $textPart = str_replace( '###' . $markerName . '###', @@ -61,10 +78,40 @@ class MailUtility $textPart ); } - $result[] = [ - 'type' => $type, - 'data' => $textPart, - ]; + switch($type) { + case 'table': + case 'tableLayout': + if ( + $result[count($result) - 1]['type'] == $type + && count($result[count($result) - 1]['data']) == 1 + ) { + $result[count($result) - 1]['data'][] = $textPart; + } else { + $result[] = [ + 'type' => $type, + 'data' => [$textPart], + ]; + } + break; + case 'list': + if ( + $result[count($result) - 1]['type'] == 'list' + ) { + $result[count($result) - 1]['data'][] = $textPart; + } else { + $result[] = [ + 'type' => 'list', + 'data' => [$textPart], + ]; + } + break; + default: + $result[] = [ + 'type' => $type, + 'data' => $textPart, + ]; + break; + } } return $result; } @@ -107,12 +154,22 @@ class MailUtility $htmlView->setTemplate($templateNameHtml); $textView = $objectManager->get(StandaloneView::class); if ($templatePaths) { + $partialRootPaths = $htmlView->getPartialRootPaths(); + $partialRootPaths[] = GeneralUtility::getFileAbsFileName( + 'EXT:templates_aide/Resources/Private/Partials/' + ); $htmlView->setTemplateRootPaths( $templatePaths->getTemplateRootPaths() ); + $htmlView->setPartialRootPaths( + $partialRootPaths + ); $textView->setTemplateRootPaths( $templatePaths->getTemplateRootPaths() ); + $textView->setPartialRootPaths( + $partialRootPaths + ); } else { $htmlView->getTemplatePaths()->fillDefaultsByPackageName( 'templates_aide' @@ -130,6 +187,9 @@ class MailUtility foreach ($data as $row) { switch($row['type']) { case 'text': + case 'table': + case 'tableLayout': + case 'list': case 'textbold': case 'headline': case 'headline2': diff --git a/Resources/Private/Partials/Mails/DefaultHtml.html b/Resources/Private/Partials/Mails/DefaultHtml.html index d30001a..464f7c9 100644 --- a/Resources/Private/Partials/Mails/DefaultHtml.html +++ b/Resources/Private/Partials/Mails/DefaultHtml.html @@ -1,23 +1,34 @@ + + + + + + + + + + + + + - - -
+
-
+
@@ -68,5 +79,136 @@ + + Data is array, can be table or list + + + + + + + + + + + + + + +
+
+ + + + + +
+ +
+ + + + +
+
+
{row.data.0 -> f:format.nl2br() -> f:format.raw()}
+
+
+
+ +
+ + + + +
+
+
{row.data.1 -> f:format.nl2br() -> f:format.raw()}
+
+
+
+ +
+
+ + + + +
+ + + + + + +
+ +
+ + + + + + +
+ + + + +
+
+
    + +
  • {dataRow -> f:format.nl2br() -> f:format.raw()}
  • +
    +
+
+
+
+
+ +
+
+ +
+ + diff --git a/Resources/Private/Partials/Mails/DefaultText.html b/Resources/Private/Partials/Mails/DefaultText.html new file mode 100644 index 0000000..ff9aa5b --- /dev/null +++ b/Resources/Private/Partials/Mails/DefaultText.html @@ -0,0 +1,50 @@ + + + + + + + + # {row.data -> f:format.nl2br() -> f:format.raw()} + + + + ## {row.data -> f:format.nl2br() -> f:format.raw()} + + + ### {row.data -> f:format.nl2br() -> f:format.raw()} + + + + {row.data -> f:format.raw()} + + {br}{br} + + + + + + + + {row.data.0 -> f:format.raw()}{br}{br}{row.data.1 -> f:format.raw()}{br} + + + {row.data.0 -> f:format.raw()}: {row.data.1 -> f:format.raw()} + + + - + {dataRow -> f:format.raw()} + + {br}{br} + + + + + + +{br}{br}{br}{br} From f427ab7cd677a03f3c26e233b420bce7b6d693a8 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Fri, 5 Nov 2021 13:14:54 +0100 Subject: [PATCH 05/10] [TASK] Move some functions to traits for reuse --- Classes/Controller/AbstractEIDController.php | 38 ++++++++- Classes/Controller/ActionController.php | 62 +------------- Classes/Traits/FormatResultTrait.php | 85 ++++++++++++++++++++ Classes/Traits/ValidationTrait.php | 61 ++++++++++++++ 4 files changed, 182 insertions(+), 64 deletions(-) create mode 100644 Classes/Traits/FormatResultTrait.php diff --git a/Classes/Controller/AbstractEIDController.php b/Classes/Controller/AbstractEIDController.php index e874211..1a97709 100644 --- a/Classes/Controller/AbstractEIDController.php +++ b/Classes/Controller/AbstractEIDController.php @@ -12,6 +12,8 @@ namespace Cjel\TemplatesAide\Controller; * ***/ +use Cjel\TemplatesAide\Traits\ValidationTrait; +use Cjel\TemplatesAide\Traits\FormatResultTrait; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Cache\CacheManager; @@ -21,10 +23,10 @@ use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Object\ObjectManager; -use TYPO3\CMS\Frontend\Plugin\AbstractPlugin; -use TYPO3\CMS\Frontend\Utility\EidUtility; use TYPO3\CMS\Extbase\Reflection\ClassSchema; use TYPO3\CMS\Extbase\Reflection\ReflectionService; +use TYPO3\CMS\Frontend\Plugin\AbstractPlugin; +use TYPO3\CMS\Frontend\Utility\EidUtility; /** * AbstractEIDController @@ -32,6 +34,18 @@ use TYPO3\CMS\Extbase\Reflection\ReflectionService; class AbstractEIDController { + /** + * ValidationTrait + */ + use ValidationTrait { + validateAgainstSchema as traitValidateAgainstSchema; + } + + /** + * FormatResultTrait + */ + use FormatResultTrait; + /** * @var BackendConfigurationManager */ @@ -99,11 +113,13 @@ class AbstractEIDController $this->apiUtility = $this->objectManager->get( \Cjel\TemplatesAide\Utility\ApiUtility::class ); - $this->configurationManager->setConfiguration(array()); $frameworkConfiguration = $this->configurationManager->getConfiguration( ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $this->getExtensionKey() ); + $this->configurationManager->setConfiguration( + $frameworkConfiguration + ); $this->settings = $frameworkConfiguration; $this->storagePids = explode( ',', @@ -241,4 +257,20 @@ class AbstractEIDController } } + /** + * return function + * + * @param array $result + * @return void + */ + protected function returnFunction( + $result = [] + ) { + $result = $this->formatResult($result); + unset($result['cid']); + unset($result['componentMode']); + unset($result['isValid']); + return $result; + } + } diff --git a/Classes/Controller/ActionController.php b/Classes/Controller/ActionController.php index 918e378..dae6c4a 100644 --- a/Classes/Controller/ActionController.php +++ b/Classes/Controller/ActionController.php @@ -3,7 +3,7 @@ namespace Cjel\TemplatesAide\Controller; /*** * - * This file is part of the "Templates Aide" Extension for TYPO3 CMS. + / This file is part of the "Templates Aide" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. @@ -415,31 +415,6 @@ class ActionController extends BaseController return false; } - /** - * shortcut to get translation - * - * @return void - */ - protected function getTranslation($key, $arguments = null) - { - $translation = LocalizationUtility::translate( - $key, - $this->getExtensionKey(), - $arguments - ); - if ($translation) { - return $translation; - } - $translation = LocalizationUtility::translate( - $key, - 'site_templates', - $arguments - ); - if ($translation) { - return $translation; - } - return null; - } /** * @@ -454,41 +429,6 @@ class ActionController extends BaseController strtolower($reflection->getShortName()); } - /** - * gets error label based on field and keyword, uses predefined extensionkey - */ - protected function getErrorLabel($field, $keyword) { - $path = 'error.' . $field . '.' . $keyword; - $errorLabel = $this->getTranslation($path); - if ($errorLabel == null) { - return $path; - } - return $errorLabel; - } - - /** - * function to add validation error manually in the controller - */ - protected function addValidationError( - $field, $keyword, $overwrite = false - ) { - $this->isValid = false; - $this->responseStatus = [400 => 'validationError']; - if (!array_key_exists($field, $this->errors) - || $overwrite == true - ) { - $this->errors[$field] = [ - 'keyword' => $keyword, - ]; - $this->errorLabels[$field] = $this->getErrorLabel( - $field, - $keyword - ); - } - } - - - /** * legacy function to prevent beaking old code * diff --git a/Classes/Traits/FormatResultTrait.php b/Classes/Traits/FormatResultTrait.php new file mode 100644 index 0000000..74dc30a --- /dev/null +++ b/Classes/Traits/FormatResultTrait.php @@ -0,0 +1,85 @@ + + * + ***/ + +/** + * ValidationTrait + */ +trait FormatResultTrait +{ + + /** + * + */ + public function formatResult() + { + if ($result == null) { + $result = []; + } + if (!empty($this->errors)) { + $result = array_merge( + $result, + ['errors' => $this->errors] + ); + } + if (!empty($this->errorLabels)) { + $result = array_merge( + $result, + ['errorLabels' => $this->errorLabels] + ); + } + if (is_array($this->responseStatus)) { + $result = array_merge( + $result, + ['errorType' => reset($this->responseStatus)] + ); + } + if ($this->pageType) { + if (is_array($this->responseStatus)) { + $this->response->setStatus( + array_key_first($this->responseStatus) + ); + } else { + $this->response->setStatus($this->responseStatus); + } + if ($this->pageType == $this->ajaxPageType) { + if ($this->environmentService->isEnvironmentInBackendMode()) { + header('Content-Type: application/json'); + } else { + $GLOBALS['TSFE']->setContentType('application/json'); + } + } + unset($result['data']); + if ($this->redirect) { + $result['redirect'] = $this->redirect; + } + if ($this->reload) { + $result['reload'] = true; + } + return json_encode($result); + } + $result = array_merge( + $result, + ['cid' => $this->contentObjectUid], + ['isValid' => $this->isValid], + ['componentMode' => $this->componentMode] + ); + if (!empty($this->ajaxEnv)) { + $result = array_merge( + $result, + ['ajaxEnv' => $this->ajaxEnv] + ); + } + return $result; + } +} diff --git a/Classes/Traits/ValidationTrait.php b/Classes/Traits/ValidationTrait.php index c001e5f..6b4a75a 100644 --- a/Classes/Traits/ValidationTrait.php +++ b/Classes/Traits/ValidationTrait.php @@ -16,6 +16,7 @@ use \Opis\JsonSchema\{ Validator, ValidationResult, ValidationError, Schema }; use Cjel\TemplatesAide\Utility\ArrayUtility; +use TYPO3\CMS\Extbase\Utility\LocalizationUtility; /** * ValidationTrait @@ -96,4 +97,64 @@ trait ValidationTrait return $validationResult; } + /** + * function to add validation error manually in the controller + */ + protected function addValidationError( + $field, $keyword, $overwrite = false + ) { + $this->isValid = false; + $this->responseStatus = [400 => 'validationError']; + if (!array_key_exists($field, $this->errors) + || $overwrite == true + ) { + $this->errors[$field] = [ + 'keyword' => $keyword, + ]; + $this->errorLabels[$field] = $this->getErrorLabel( + $field, + $keyword + ); + } + } + + /** + * gets error label based on field and keyword, uses predefined extensionkey + */ + protected function getErrorLabel($field, $keyword) { + $path = 'error.' . $field . '.' . $keyword; + $errorLabel = $this->getTranslation($path); + if ($errorLabel == null) { + return $path; + } + return $errorLabel; + } + + /** + * shortcut to get translation + * + * @return void + */ + protected function getTranslation($key, $arguments = null) + { + $translation = LocalizationUtility::translate( + $key, + $this->getExtensionKey(), + $arguments + ); + if ($translation) { + return $translation; + } + $translation = LocalizationUtility::translate( + $key, + 'site_templates', + $arguments + ); + if ($translation) { + return $translation; + } + return null; + } + + } From cf387b1af7fdceed42b15d92f114b09b79a34488 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Fri, 5 Nov 2021 14:23:39 +0100 Subject: [PATCH 06/10] [TASK] Improve result handling for apis --- Classes/Controller/AbstractEIDController.php | 19 +++++++++++++++++-- Classes/Traits/FormatResultTrait.php | 3 +-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Classes/Controller/AbstractEIDController.php b/Classes/Controller/AbstractEIDController.php index 1a97709..dfd9d64 100644 --- a/Classes/Controller/AbstractEIDController.php +++ b/Classes/Controller/AbstractEIDController.php @@ -266,11 +266,26 @@ class AbstractEIDController protected function returnFunction( $result = [] ) { - $result = $this->formatResult($result); + $result = $this->formatResult($result, 'asd'); unset($result['cid']); unset($result['componentMode']); unset($result['isValid']); - return $result; + if ($result) { + if (!empty($this->errors)) { + return $result; + } else { + return [ + 'metadata' => [ + 'total' => count($result), + 'count' => count($result), + ], + 'result' => $result, + ]; + } + } else { + return []; + } + //return $result; } } diff --git a/Classes/Traits/FormatResultTrait.php b/Classes/Traits/FormatResultTrait.php index 74dc30a..c1bac0e 100644 --- a/Classes/Traits/FormatResultTrait.php +++ b/Classes/Traits/FormatResultTrait.php @@ -21,8 +21,7 @@ trait FormatResultTrait /** * */ - public function formatResult() - { + public function formatResult($result) { if ($result == null) { $result = []; } From 4a1ae9a7a210495d5e568d48f6dd0e8e98c25e89 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Sun, 14 Nov 2021 19:02:51 +0100 Subject: [PATCH 07/10] [FEATURE] Add attachment option to mailutility --- Classes/Utility/MailUtility.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Classes/Utility/MailUtility.php b/Classes/Utility/MailUtility.php index 6f16ebe..db456d2 100644 --- a/Classes/Utility/MailUtility.php +++ b/Classes/Utility/MailUtility.php @@ -280,6 +280,13 @@ class MailUtility $bodydataText[] = $textRow; $bodydataHtml[] = $htmlRow; break; + case 'attachment': + $mail->attach(new \Swift_Attachment( + $row['data'][0], + $row['data'][1], + $row['data'][2] + )); + break; case 'attachmentBase64': $attachmentdata = explode(',', $row['data']); preg_match('/\w*:(.*);\w*/', $attachmentdata[0], $matches); From 04041fa56488412ce45e3546e0656ea7f497e9a0 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Sun, 14 Nov 2021 19:03:55 +0100 Subject: [PATCH 08/10] [FEATURE] Add option to search full typoscript to site config utility --- Classes/Utility/SiteConfigUtility.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Classes/Utility/SiteConfigUtility.php b/Classes/Utility/SiteConfigUtility.php index d14b8be..1a1041a 100644 --- a/Classes/Utility/SiteConfigUtility.php +++ b/Classes/Utility/SiteConfigUtility.php @@ -27,8 +27,10 @@ class SiteConfigUtility * @var string $path * @return string */ - public static function getByPath($path) - { + public static function getByPath( + $path, + $limitToSiteConfig = true + ) { $pathParts = explode('.', $path); $objectManager = GeneralUtility::makeInstance( ObjectManager::class @@ -40,7 +42,10 @@ class SiteConfigUtility ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT ); $typoscript = GeneralUtility::removeDotsFromTS($typoscript); - $siteConfig = $typoscript['config']['site']; + $siteConfig = $typoscript; + if ($limitToSiteConfig) { + $siteConfig = $typoscript['config']['site']; + } $current = &$siteConfig; foreach ($pathParts as $key) { $current = &$current[$key]; From 55b9ae220c466ce56b0e20b775d71b41edbb00da Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Sun, 14 Nov 2021 19:05:33 +0100 Subject: [PATCH 09/10] [TASK] Don't hide new pages in dev environment --- Resources/Private/PageTSConfig/default.tsconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Resources/Private/PageTSConfig/default.tsconfig b/Resources/Private/PageTSConfig/default.tsconfig index ffb5fbd..31b6307 100644 --- a/Resources/Private/PageTSConfig/default.tsconfig +++ b/Resources/Private/PageTSConfig/default.tsconfig @@ -1 +1,5 @@ + +[applicationContext = Development] +TCAdefaults.pages.hidden = 0 +[end] From 76c9a738f71507647a1b535f5c5150d57bdc8a07 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Sun, 14 Nov 2021 20:55:09 +0100 Subject: [PATCH 10/10] [BUGFIX] Create correct extension key to get configuration --- Classes/Traits/DependencyInjectionTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Traits/DependencyInjectionTrait.php b/Classes/Traits/DependencyInjectionTrait.php index 27dbbc8..d2ccc13 100644 --- a/Classes/Traits/DependencyInjectionTrait.php +++ b/Classes/Traits/DependencyInjectionTrait.php @@ -88,7 +88,7 @@ trait DependencyInjectionTrait ); $frameworkConfiguration = $this->configurationManager->getConfiguration( ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, - $this->getExtensionKey() + str_replace('_', '', $this->getExtensionKey()) ); $this->configurationManager->setConfiguration( $frameworkConfiguration