diff --git a/typo3/sysext/styleguide/Classes/Service/KauderwelschService.php b/typo3/sysext/styleguide/Classes/Service/KauderwelschService.php index a076cfa4bfe0656dc4cb7156d60e53b43bc259ab..a4c737e0d8204d70d71649c9ce83ab3366ab7986 100644 --- a/typo3/sysext/styleguide/Classes/Service/KauderwelschService.php +++ b/typo3/sysext/styleguide/Classes/Service/KauderwelschService.php @@ -26,8 +26,6 @@ final class KauderwelschService { /** * Lorem ipsum test with fixed length. - * - * @return string */ public function getLoremIpsum(): string { @@ -36,8 +34,6 @@ final class KauderwelschService /** * Lorem ipsum test with fixed length and HTML in it. - * - * @return string */ public function getLoremIpsumHtml(): string { @@ -46,8 +42,6 @@ final class KauderwelschService /** * Get a single word - * - * @return string */ public function getWord(): string { @@ -64,8 +58,6 @@ final class KauderwelschService /** * Get an integer - * - * @return int */ public function getInteger(): int { @@ -74,8 +66,6 @@ final class KauderwelschService /** * Timestamp of a day before 1970 - * - * @return int */ public function getDateTimestamp(): int { @@ -85,8 +75,6 @@ final class KauderwelschService /** * Timestamp of a day before 1970 with seconds - * - * @return int */ public function getDatetimeTimestamp(): int { @@ -96,8 +84,6 @@ final class KauderwelschService /** * Date before 1970 as string - * - * @return string */ public function getDateString(): string { @@ -107,8 +93,6 @@ final class KauderwelschService /** * Date before 1970 with seconds as string - * - * @return string */ public function getDatetimeString(): string { @@ -118,8 +102,6 @@ final class KauderwelschService /** * Get a float - * - * @return float */ public function getFloat(): float { @@ -128,8 +110,6 @@ final class KauderwelschService /** * Get a link - * - * @return string */ public function getLink(): string { @@ -138,18 +118,22 @@ final class KauderwelschService /** * Get a valid email - * - * @return string */ public function getEmail(): string { return 'foo@example.com'; } + /** + * Get a valid uuid v4 / v7 - both have same format + */ + public function getUuid(): string + { + return '2cc152d0-08b4-438b-92e5-4b6e8d90b465'; + } + /** * Get a color as hex string - * - * @return string */ public function getHexColor(): string { diff --git a/typo3/sysext/styleguide/Classes/TcaDataGenerator/FieldGenerator/TypeUuid.php b/typo3/sysext/styleguide/Classes/TcaDataGenerator/FieldGenerator/TypeUuid.php new file mode 100644 index 0000000000000000000000000000000000000000..cf91c68a15fc162a5cdd7b53dc6f84c53357feb8 --- /dev/null +++ b/typo3/sysext/styleguide/Classes/TcaDataGenerator/FieldGenerator/TypeUuid.php @@ -0,0 +1,47 @@ +<?php + +declare(strict_types=1); + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +namespace TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGenerator; + +use TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGeneratorInterface; + +/** + * Generate data for type=uuid fields + * + * @internal + */ +final class TypeUuid extends AbstractFieldGenerator implements FieldGeneratorInterface +{ + /** + * @var array General match if type=uuid + */ + protected $matchArray = [ + 'fieldConfig' => [ + 'config' => [ + 'type' => 'uuid', + ], + ], + ]; + + /** + * Returns the generated value to be inserted into DB for this field + */ + public function generate(array $data): string + { + return $this->kauderwelschService->getUuid(); + } +} diff --git a/typo3/sysext/styleguide/Classes/TcaDataGenerator/FieldGeneratorResolver.php b/typo3/sysext/styleguide/Classes/TcaDataGenerator/FieldGeneratorResolver.php index 5b8c926b4a18e7f960e70e88d66aa964df790019..2f28391fa876d23e3394352d2300a6ff05d6e502 100644 --- a/typo3/sysext/styleguide/Classes/TcaDataGenerator/FieldGeneratorResolver.php +++ b/typo3/sysext/styleguide/Classes/TcaDataGenerator/FieldGeneratorResolver.php @@ -102,6 +102,8 @@ final class FieldGeneratorResolver FieldGenerator\TypePassthrough::class, // General type=user generator FieldGenerator\TypeUser::class, + // General type=uuid generator + FieldGenerator\TypeUuid::class, // type=group FieldGenerator\TypeGroupFal::class, diff --git a/typo3/sysext/styleguide/Configuration/TCA/tx_styleguide_elements_basic.php b/typo3/sysext/styleguide/Configuration/TCA/tx_styleguide_elements_basic.php index e04732ac5e86a7ed351b563d170f14a853359652..60d21674fc605eb570384a7deb7e9885bb86323b 100644 --- a/typo3/sysext/styleguide/Configuration/TCA/tx_styleguide_elements_basic.php +++ b/typo3/sysext/styleguide/Configuration/TCA/tx_styleguide_elements_basic.php @@ -2,7 +2,7 @@ return [ 'ctrl' => [ - 'title' => 'Form engine elements - input, text, checkbox, radio, none, passthrough, user', + 'title' => 'Form engine elements - input, text, uuid, checkbox, radio, none, passthrough, user', 'label' => 'uid', 'tstamp' => 'tstamp', 'crdate' => 'crdate', @@ -1088,6 +1088,30 @@ backend_layout { ], ], + 'uuid_1' => [ + 'label' => 'uuid_1', + 'description' => 'uuid', + 'config' => [ + 'type' => 'uuid', + ], + ], + 'uuid_2' => [ + 'label' => 'uuid_2', + 'description' => 'uuid without copy icon', + 'config' => [ + 'type' => 'uuid', + 'enableCopyToClipboard' => false, + ], + ], + 'uuid_3' => [ + 'label' => 'uuid_3', + 'description' => 'uuid version 7', + 'config' => [ + 'type' => 'uuid', + 'version' => 7, + ], + ], + 'checkbox_1' => [ 'label' => 'checkbox_1', 'description' => 'field description', @@ -1897,6 +1921,8 @@ backend_layout { text_1, text_2, text_3, text_4, text_5, text_6, text_7, text_9, text_10, text_11, text_12, text_13, text_18, text_14, text_15, text_16, text_17, text_19, text_20, + --div--;uuid, + uuid_1, uuid_2, uuid_3, --div--;check, checkbox_1, checkbox_9, checkbox_2, checkbox_17, checkbox_25, checkbox_18, checkbox_24, checkbox_19, checkbox_26, checkbox_20, checkbox_21, checkbox_22, checkbox_23, checkbox_3, checkbox_4, checkbox_6, checkbox_7, checkbox_8,