Skip to content

Commit

Permalink
[TASK] Make author fields optional
Browse files Browse the repository at this point in the history
Due to data minimization, users should not be required to enter their email address or website to use the Site Package Builder.

The vendor many ppl use is not the same
like the company name. Also not everyone works in a company (freelancers, universities, ..) and some customers or organizations want their own vendor no matter who created the site package.

Make vendor its own field.
  • Loading branch information
linawolf committed Nov 24, 2024
1 parent 51b01cc commit 779582f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
1 change: 0 additions & 1 deletion src/Controller/Api/SitepackageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
2 changes: 0 additions & 2 deletions src/Controller/SitepackageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -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()));
Expand Down
9 changes: 7 additions & 2 deletions src/Entity/Sitepackage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')]
Expand All @@ -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')]
Expand Down
10 changes: 1 addition & 9 deletions src/Entity/Sitepackage/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/Form/AuthorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions src/Form/SitepackageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '',
Expand Down

0 comments on commit 779582f

Please sign in to comment.