diff --git a/src/Controller/Api/SitepackageController.php b/src/Controller/Api/SitepackageController.php index c90d04d2..b4ecec3a 100644 --- a/src/Controller/Api/SitepackageController.php +++ b/src/Controller/Api/SitepackageController.php @@ -58,7 +58,6 @@ public function createSitepackage(Request $request): Response $sitepackage = $this->serializer->deserialize($content, Sitepackage::class, 'json'); $this->validateObject($sitepackage); - $sitepackage->setVendorName(StringUtility::stringToUpperCamelCase($sitepackage->getAuthor()->getCompany())); $sitepackage->setVendorNameAlternative(StringUtility::camelCaseToLowerCaseDashed($sitepackage->getVendorName())); $sitepackage->setPackageName(StringUtility::stringToUpperCamelCase($sitepackage->getTitle())); $sitepackage->setPackageNameAlternative(StringUtility::camelCaseToLowerCaseDashed($sitepackage->getPackageName())); diff --git a/src/Controller/SitepackageController.php b/src/Controller/SitepackageController.php index 63fc92b5..7e3e7a7d 100644 --- a/src/Controller/SitepackageController.php +++ b/src/Controller/SitepackageController.php @@ -54,7 +54,6 @@ public function new(Request $request): Response $form = $this->createNewSitepackageForm($sitepackage); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $sitepackage->setVendorName(StringUtility::stringToUpperCamelCase($sitepackage->getAuthor()->getCompany())); $sitepackage->setVendorNameAlternative(StringUtility::camelCaseToLowerCaseDashed($sitepackage->getVendorName())); $sitepackage->setPackageName(StringUtility::stringToUpperCamelCase($sitepackage->getTitle())); $sitepackage->setPackageNameAlternative(StringUtility::camelCaseToLowerCaseDashed($sitepackage->getPackageName())); @@ -90,7 +89,6 @@ public function edit(Request $request): Response $form = $this->createEditSitePackageForm($sitepackage); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $sitepackage->setVendorName(StringUtility::stringToUpperCamelCase($sitepackage->getAuthor()->getCompany())); $sitepackage->setVendorNameAlternative(StringUtility::camelCaseToLowerCaseDashed($sitepackage->getVendorName())); $sitepackage->setPackageName(StringUtility::stringToUpperCamelCase($sitepackage->getTitle())); $sitepackage->setPackageNameAlternative(StringUtility::camelCaseToLowerCaseDashed($sitepackage->getPackageName())); diff --git a/src/Entity/Sitepackage.php b/src/Entity/Sitepackage.php index e3b06272..9a36dcf7 100644 --- a/src/Entity/Sitepackage.php +++ b/src/Entity/Sitepackage.php @@ -45,8 +45,6 @@ class Sitepackage implements \JsonSerializable #[OA\Property(type: 'float', example: 13.4)] private float $typo3Version = 13.4; - private string $vendorName; - private string $vendorNameAlternative; #[Assert\NotBlank(message: 'Please enter a title for your site package')] @@ -56,6 +54,13 @@ class Sitepackage implements \JsonSerializable #[OA\Property(type: 'string', example: 'My Sitepackage')] private string $title; + #[Assert\NotBlank(message: 'Please enter a vendor, CamelCase')] + #[Assert\Length(min: 3)] + #[Assert\Regex(pattern: '/^[A-Za-z0-9]+$/', message: 'Only letters and numbers are allowed')] + #[Serializer\Type('string')] + #[OA\Property(type: 'string', example: 'MyCompany')] + private string $vendorName; + #[Assert\Regex(pattern: '/^[A-Za-z0-9\x7f-\xff .,:!?&-]+$/', message: 'Only letters, numbers and spaces are allowed')] #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'Project Configuration for Client')] diff --git a/src/Entity/Sitepackage/Author.php b/src/Entity/Sitepackage/Author.php index bb59ff33..2e3129e2 100644 --- a/src/Entity/Sitepackage/Author.php +++ b/src/Entity/Sitepackage/Author.php @@ -32,27 +32,19 @@ */ class Author implements \JsonSerializable { - #[Assert\NotBlank(message: "Please enter the authors' name.")] - #[Assert\Length(min: 3)] #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'J. Doe')] private string $name; - #[Assert\NotBlank(message: "Please enter the authors' email address.")] - #[Assert\Email(message: "The email '{{ value }}' is not a valid email.")] #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'info@typo3.com')] private string $email; - #[Assert\NotBlank(message: "Please enter the authors' company.")] - #[Assert\Length(min: 3)] - #[Assert\Regex(pattern: '/^[A-Za-z0-9\x7f-\xff .:&-]+$/', message: 'Only letters, numbers and spaces are allowed')] + #[Assert\Regex(pattern: '/^[\p{L}\p{N} .:&-]+$/u', message: 'Invalid characters in company name.')] #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'TYPO3')] private string $company; - #[Assert\NotBlank(message: "Please enter the authors' homepage URL.")] - #[Assert\Url] #[Serializer\Type('string')] #[OA\Property(type: 'string', example: 'https://typo3.com')] private string $homepage; diff --git a/src/Form/AuthorType.php b/src/Form/AuthorType.php index 69c262ad..0f3913a7 100644 --- a/src/Form/AuthorType.php +++ b/src/Form/AuthorType.php @@ -36,24 +36,32 @@ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('name', TextType::class, [ + 'required' => false, + 'empty_data' => '', 'attr' => [ 'autocomplete' => 'off', 'placeholder' => 'John Doe', ], ]) ->add('email', EmailType::class, [ + 'required' => false, + 'empty_data' => '', 'attr' => [ 'autocomplete' => 'off', 'placeholder' => 'john.doe@example.com', ], ]) ->add('company', TextType::class, [ + 'required' => false, + 'empty_data' => '', 'attr' => [ 'autocomplete' => 'off', 'placeholder' => 'Company Inc.', ], ]) ->add('homepage', TextType::class, [ + 'required' => false, + 'empty_data' => '', 'attr' => [ 'autocomplete' => 'off', 'placeholder' => 'https://www.example.com', diff --git a/src/Form/SitepackageType.php b/src/Form/SitepackageType.php index 068e3b03..46ee46ec 100644 --- a/src/Form/SitepackageType.php +++ b/src/Form/SitepackageType.php @@ -66,6 +66,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'placeholder' => 'My Sitepackage', ], ]) + ->add('vendorName', TextType::class, [ + 'attr' => [ + 'autocomplete' => 'off', + 'placeholder' => 'MyCompany', + ], + ]) ->add('description', TextareaType::class, [ 'required' => false, 'empty_data' => '',