diff --git a/src/Controller/SitePackageController.php b/src/Controller/SitePackageController.php index 5d43f672..9025521e 100644 --- a/src/Controller/SitePackageController.php +++ b/src/Controller/SitePackageController.php @@ -54,7 +54,7 @@ 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->setVendorName(StringUtility::stringToUpperCamelCase($sitepackage->getVendorName())); $sitepackage->setVendorNameAlternative(StringUtility::camelCaseToLowerCaseDashed($sitepackage->getVendorName())); $sitepackage->setPackageName(StringUtility::stringToUpperCamelCase($sitepackage->getTitle())); $sitepackage->setPackageNameAlternative(StringUtility::camelCaseToLowerCaseDashed($sitepackage->getPackageName())); @@ -90,7 +90,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 e071ede6..28256b18 100644 --- a/src/Entity/SitePackage.php +++ b/src/Entity/SitePackage.php @@ -36,8 +36,6 @@ class SitePackage implements \JsonSerializable #[Assert\NotBlank] private float $typo3Version = 13.4; - private string $vendorName; - private string $vendorNameAlternative; #[Assert\NotBlank(message: 'Please enter a title for your site package')] @@ -45,6 +43,11 @@ class SitePackage implements \JsonSerializable #[Assert\Regex(pattern: '/^[A-Za-z0-9\x7f-\xff .:&-]+$/', message: 'Only letters, numbers and spaces are allowed')] 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')] + private string $vendorName; + #[Assert\Regex(pattern: '/^[A-Za-z0-9\x7f-\xff .,:!?&-]+$/', message: 'Only letters, numbers and spaces are allowed')] private string $description; diff --git a/src/Entity/SitePackage/Author.php b/src/Entity/SitePackage/Author.php index d59891a8..28c59b05 100644 --- a/src/Entity/SitePackage/Author.php +++ b/src/Entity/SitePackage/Author.php @@ -30,20 +30,14 @@ */ class Author implements \JsonSerializable { - #[Assert\NotBlank(message: "Please enter the authors' name.")] - #[Assert\Length(min: 3)] private string $name; - #[Assert\NotBlank(message: "Please enter the authors' email address.")] #[Assert\Email(message: "The email '{{ value }}' is not a valid email.")] 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.')] private string $company; - #[Assert\NotBlank(message: "Please enter the authors' homepage URL.")] #[Assert\Url] private string $homepage; diff --git a/src/Form/AuthorType.php b/src/Form/AuthorType.php index 95c97b3b..5426326a 100644 --- a/src/Form/AuthorType.php +++ b/src/Form/AuthorType.php @@ -36,6 +36,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('name', TextType::class, [ + 'required' => false, + 'empty_data' => '', 'attr' => [ 'autocomplete' => 'off', 'placeholder' => 'John Doe', @@ -45,6 +47,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], ]) ->add('email', EmailType::class, [ + 'required' => false, + 'empty_data' => '', 'attr' => [ 'autocomplete' => 'off', 'placeholder' => 'john.doe@example.com', @@ -54,6 +58,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], ]) ->add('company', TextType::class, [ + 'required' => false, + 'empty_data' => '', 'attr' => [ 'autocomplete' => 'off', 'placeholder' => 'Company Inc.', @@ -63,6 +69,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) ], ]) ->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 bdca6fff..0577ecd9 100644 --- a/src/Form/SitePackageType.php +++ b/src/Form/SitePackageType.php @@ -78,7 +78,16 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'placeholder' => 'My Site Package', ], 'documentation' => [ - 'example' => 'My SitePackage', + 'example' => 'My Site Package', + ], + ]) + ->add('vendor_name', TextType::class, [ + 'attr' => [ + 'autocomplete' => 'off', + 'placeholder' => 'MyCompany', + ], + 'documentation' => [ + 'example' => 'MyCompany', ], ]) ->add('description', TextareaType::class, [ diff --git a/templates/sitepackage/success.html.twig b/templates/sitepackage/success.html.twig index c42cb907..5b2865af 100644 --- a/templates/sitepackage/success.html.twig +++ b/templates/sitepackage/success.html.twig @@ -105,17 +105,27 @@