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 diff --git a/Classes/Traits/ValidationTrait.php b/Classes/Traits/ValidationTrait.php index 6b4a75a..945fd9c 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 Sarhan\Flatten\Flatten; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; /** @@ -39,6 +40,78 @@ trait ValidationTrait */ protected $errorLabels = []; + /** + * validate objects + * + * @param $input + * @param schema + * @return void + */ + protected function convertInputBySchema($input, $schema) + { + $flatten = new Flatten(); + $schemaFlat = $flatten->flattenToArray($schema); + $typesList = []; + $formatsList = []; + foreach ($schemaFlat as $index => $row) { + $dataIndex = preg_replace( + '/(\.)(properties\.|items\.)/', + '$1', + $index + ); + $dataIndex = preg_replace( + '/^properties\./', + '', + $dataIndex + ); + $dataIndex = preg_replace( + '/\.(type|format)$/', + '', + $dataIndex + ); + if (substr($index, -5) == '.type') { + $typesList[$dataIndex] = $row; + } + if (substr($index, -7) == '.format') { + $formatsList[$dataIndex] = $row; + } + } + foreach ($input as $index => $row) { + $rowType = $typesList[$index]; + $formatType = $formatsList[$index]; + if (!$rowType) { + continue; + } + switch ($rowType) { + case 'integer': + if (is_numeric($row)) { + settype($input[$index], $rowType); + } + break; + case 'boolean': + $testResult = filter_var( + $row, + FILTER_VALIDATE_BOOLEAN, + [FILTER_NULL_ON_FAILURE] + ); + if ($testResult === true || $testResult === false) { + $input[$index] = $testResult; + } + case 'string': + switch ($formatType) { + case 'date': + $row = \DateTime::createFromFormat( + 'Y-m-d H:i:s', + $row . ' 00:00:00', + ); + break; + } + break; + } + } + return $input; + } + /** * validate objects * @@ -68,9 +141,6 @@ trait ValidationTrait if (!$validationResult->isValid()) { $this->isValid = false; $this->responseStatus = [400 => 'validationError']; - //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump( - // $validationResult->getErrors(), false, 9, true - //); foreach ($validationResult->getErrors() as $error){ $field = implode('.', $error->dataPointer()); if ($error->keyword() == 'required') { diff --git a/Classes/Utility/ArrayUtility.php b/Classes/Utility/ArrayUtility.php index 7f2a7a0..f43c961 100644 --- a/Classes/Utility/ArrayUtility.php +++ b/Classes/Utility/ArrayUtility.php @@ -22,7 +22,11 @@ class ArrayUtility */ public static function toObject($array) { if (is_array($array)) { - return (object) array_map([__CLASS__, __METHOD__], $array); + if (self::isAssoc($array)) { + return (object) array_map([__CLASS__, __METHOD__], $array); + } else { + return array_map([__CLASS__, __METHOD__], $array); + } } else { return $array; } @@ -46,4 +50,15 @@ class ArrayUtility return $array; } + + /** + * + */ + public static function isAssoc(array $arr) { + if (array() === $arr) { + return false; + } + return array_keys($arr) !== range(0, count($arr) - 1); + } + } 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); 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]; 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] diff --git a/composer.json b/composer.json index 3b3fc76..0134a05 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,8 @@ } ], "require": { - "typo3/cms-core": "8.7.0 - 9.5.99" + "typo3/cms-core": "8.7.0 - 10.99.99", + "sarhan/php-flatten": "^4.0" }, "autoload": { "psr-4": { diff --git a/composer.json.orig b/composer.json.orig new file mode 100644 index 0000000..abf0a9e --- /dev/null +++ b/composer.json.orig @@ -0,0 +1,33 @@ +{ + "name": "cjel/templates-aide", + "type": "typo3-cms-extension", + "description": "", + "authors": [ + { + "name": "Philipp Dieter", + "role": "Developer" + } + ], + "require": { +<<<<<<< HEAD + "typo3/cms-core": "8.7.0 - 9.5.99", + "sarhan/php-flatten": "^4.0" +======= + "typo3/cms-core": "8.7.0 - 10.99.99" +>>>>>>> 4a4b809d13bd33b85d84f03eba5edb603d74abfb + }, + "autoload": { + "psr-4": { + "Cjel\\TemplatesAide\\": "Classes" + } + }, + "autoload-dev": { + "psr-4": { + "Cjel\\TemplatesAide\\Tests\\": "Tests" + } + }, + "replace": { + "templates_aide": "self.version", + "typo3-ter/templates-aide": "self.version" + } +} diff --git a/ext_emconf.php b/ext_emconf.php index 1340658..f3e4cb9 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -23,7 +23,7 @@ $EM_CONF[$_EXTKEY] = [ 'version' => '0.0.1', 'constraints' => [ 'depends' => [ - 'typo3' => '8.7.0-9.5.99', + 'typo3' => '8.7.0-10.99.99', ], 'conflicts' => [], 'suggests' => [],