Skip to content

Commit

Permalink
Merge pull request #3607 from plentymarkets/test/inline_text
Browse files Browse the repository at this point in the history
feat: eu responsible text alignment
  • Loading branch information
teodorrosusn authored Nov 7, 2024
2 parents 3e49a58 + a14321c commit 0ae02f2
Show file tree
Hide file tree
Showing 9 changed files with 288 additions and 45 deletions.
2 changes: 0 additions & 2 deletions resources/lang/de/Template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,6 @@ singleItemExclusive = "zzgl."
singleItemExclVAT = "zzgl. ges. MwSt."
singleItemExternalVariationId = "Varianten-ID"
singleItemEuResponsiblePerson = "EU-Verantwortlicher"
singleItemEuResponsiblePersonTitle = "VERANTWORTLICHE STELLE IN DER EU"
singleItemEuResponsiblePersonBody = "Ein Wirtschaftsakteur mit Sitz innerhalb der EU, der sicherstellt, dass das Produkt allen erforderlichen Vorschriften entspricht."
singleItemFootnote1 = "*"
singleItemFootnote12 = "*, **"
singleItemFootnote2 = "**"
Expand Down
2 changes: 0 additions & 2 deletions resources/lang/en/Template.properties
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,6 @@ singleItemExclusive = "excl."
singleItemExclVAT = "Excl. VAT"
singleItemExternalVariationId = "Variation ID"
singleItemEuResponsiblePerson = "EU-Responsible Person"
singleItemEuResponsiblePersonTitle = "RESPONSIBLE ENTITY IN THE EU"
singleItemEuResponsiblePersonBody = "An economic operator based within the EU who ensures that the product complies with all necessary regulations."
singleItemFootnote1 = "*"
singleItemFootnote12 = "*, **"
singleItemFootnote2 = "**"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Ceres\Builders\EuManufacturer\Abstracts;

use Ceres\Helper\ShopBuilderHelper;

abstract class AbstractEuManufacturerBuilder
{
/**
* Constructs the actual field provider structure that's used to generate shop builder data fields.
*
* @param string $provider
*
* @return string
*/
protected function getShopBuilderDataFieldProvider(string $provider): string
{
/** @var ShopBuilderHelper $shopBuilderHelper */
$shopBuilderHelper = pluginApp(ShopBuilderHelper::class);

return $shopBuilderHelper->getShopBuilderDataFieldProvider(
'ManufacturerDataFieldProvider::' . $provider,
['item.manufacturer.' . $provider, null, null]
);
}
}
40 changes: 40 additions & 0 deletions src/Builders/EuManufacturer/Address/DetailedAddressBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Ceres\Builders\EuManufacturer\Address;

use Ceres\Builders\EuManufacturer\Abstracts\AbstractEuManufacturerBuilder;
use Ceres\ShopBuilder\DataFieldProvider\Item\ManufacturerDataFieldProvider;

class DetailedAddressBuilder extends AbstractEuManufacturerBuilder
{
/** @var array */
public array $results = [];

/**
* @return DetailedAddressBuilder
*/
public function withStreet(): DetailedAddressBuilder
{
$this->results[] = $this->getShopBuilderDataFieldProvider(ManufacturerDataFieldProvider::RESPONSIBLE_STREET);

return $this;
}

/**
* @return DetailedAddressBuilder
*/
public function withHouseNumber(): DetailedAddressBuilder
{
$this->results[] = $this->getShopBuilderDataFieldProvider(ManufacturerDataFieldProvider::RESPONSIBLE_HOUSE_NO);

return $this;
}

/**
* @return string
*/
public function build(): string
{
return implode(' ', $this->results);
}
}
50 changes: 50 additions & 0 deletions src/Builders/EuManufacturer/Address/GeneralAddressBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Ceres\Builders\EuManufacturer\Address;

use Ceres\Builders\EuManufacturer\Abstracts\AbstractEuManufacturerBuilder;
use Ceres\ShopBuilder\DataFieldProvider\Item\ManufacturerDataFieldProvider;

class GeneralAddressBuilder extends AbstractEuManufacturerBuilder
{
/** @var array */
public array $results = [];

/**
* @return $this
*/
public function withCity(): GeneralAddressBuilder
{
$this->results[] = $this->getShopBuilderDataFieldProvider(ManufacturerDataFieldProvider::RESPONSIBLE_TOWN);

return $this;
}

/**
* @return GeneralAddressBuilder
*/
public function withCountry(): GeneralAddressBuilder
{
$this->results[] = $this->getShopBuilderDataFieldProvider(ManufacturerDataFieldProvider::RESPONSIBLE_COUNTRY);

return $this;
}

/**
* @return GeneralAddressBuilder
*/
public function withPostCode(): GeneralAddressBuilder
{
$this->results[] = $this->getShopBuilderDataFieldProvider(ManufacturerDataFieldProvider::RESPONSIBLE_POST_CODE);

return $this;
}

/**
* @return string
*/
public function build(): string
{
return implode(' ', $this->results);
}
}
113 changes: 113 additions & 0 deletions src/Builders/EuManufacturer/EuManufacturerBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

namespace Ceres\Builders\EuManufacturer;

use Ceres\Builders\EuManufacturer\Abstracts\AbstractEuManufacturerBuilder;
use Ceres\Builders\EuManufacturer\Address\DetailedAddressBuilder;
use Ceres\Builders\EuManufacturer\Address\GeneralAddressBuilder;
use Ceres\ShopBuilder\DataFieldProvider\Item\ManufacturerDataFieldProvider;
use Ceres\Widgets\Helper\Factories\PresetWidgetFactory;

class EuManufacturerBuilder extends AbstractEuManufacturerBuilder
{
/** @var array */
public array $results = [];

/** @var DetailedAddressBuilder */
public DetailedAddressBuilder $detailedAddressBuilder;
/** @var GeneralAddressBuilder */
public GeneralAddressBuilder $generalAddressBuilder;

/**
* @param DetailedAddressBuilder $detailedAddressBuilder
* @param GeneralAddressBuilder $generalAddressBuilder
*/
public function __construct(DetailedAddressBuilder $detailedAddressBuilder,
GeneralAddressBuilder $generalAddressBuilder
) {
$this->detailedAddressBuilder = $detailedAddressBuilder;
$this->generalAddressBuilder = $generalAddressBuilder;
}

/**
* @return EuManufacturerBuilder
*/
public function withName(): EuManufacturerBuilder
{
$this->results[] = $this->getShopBuilderDataFieldProvider(ManufacturerDataFieldProvider::RESPONSIBLE_NAME);

return $this;
}

/**
* @return EuManufacturerBuilder
*/
public function withDetailedAddress(): EuManufacturerBuilder
{
$this->detailedAddressBuilder->withStreet();
$this->detailedAddressBuilder->withHouseNumber();
$this->results[] = $this->detailedAddressBuilder->build();

return $this;
}

/**
* @return EuManufacturerBuilder
*/
public function withGeneralAddress(): EuManufacturerBuilder
{
$this->generalAddressBuilder->withCity();
$this->generalAddressBuilder->withCountry();
$this->generalAddressBuilder->withPostCode();
$this->results[] = $this->generalAddressBuilder->build();

return $this;
}

/**
* @return EuManufacturerBuilder
*/
public function withMail(): EuManufacturerBuilder
{
$this->results[] = $this->getShopBuilderDataFieldProvider(ManufacturerDataFieldProvider::RESPONSIBLE_EMAIL);

return $this;
}

/**
* @return EuManufacturerBuilder
*/
public function withPhoneNumber(): EuManufacturerBuilder
{
$this->results[] = $this->getShopBuilderDataFieldProvider(ManufacturerDataFieldProvider::RESPONSIBLE_PHONE);

return $this;
}

/**
* @param PresetWidgetFactory $presetWidgetFactory
* @param string $uuidEuResponsiblePerson
*
* @return void
*/
public function build(PresetWidgetFactory $presetWidgetFactory, string $uuidEuResponsiblePerson): void
{
foreach ($this->results as $result) {
$presetWidgetFactory->createChild($uuidEuResponsiblePerson, 'Ceres::InlineTextWidget')
->withSetting('appearance','none')
->withSetting('spacing.customPadding', true)
->withSetting('spacing.padding.left.value', 0)
->withSetting('spacing.padding.left.unit', null)
->withSetting('spacing.padding.right.value', 0)
->withSetting('spacing.padding.right.unit', null)
->withSetting('spacing.padding.top.value', 0)
->withSetting('spacing.padding.top.unit', null)
->withSetting('spacing.padding.bottom.value', 0)
->withSetting('spacing.padding.bottom.unit', null)
->withSetting(
'text',
$result
);
}
}
}
21 changes: 21 additions & 0 deletions src/Helper/ShopBuilderHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Ceres\Helper;

class ShopBuilderHelper
{
/**
* Constructs the actual field provider structure that's used to generate shop builder data fields.
*
* @param string $provider
* @param array $itemDataFields
* @return string
*/
public function getShopBuilderDataFieldProvider(string $provider, array $itemDataFields)
{
$query = "{# SHOPBUILDER:DATA_FIELD Ceres\\ShopBuilder\\DataFieldProvider\\Item\\$provider #}";
$dataFields = implode(",", $itemDataFields);
$query .= "{{ item_data_field($dataFields)}}";
return $query;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
class ManufacturerDataFieldProvider extends DataFieldProvider
{
/** @var string */
private const RESPONSIBLE_NAME = 'responsibleName';
public const RESPONSIBLE_NAME = 'responsibleName';
/** @var string */
private const RESPONSIBLE_STREET = 'responsibleStreet';
public const RESPONSIBLE_STREET = 'responsibleStreet';
/** @var string */
private const RESPONSIBLE_HOUSE_NO = 'responsibleHouseNo';
public const RESPONSIBLE_HOUSE_NO = 'responsibleHouseNo';
/** @var string */
private const RESPONSIBLE_POST_CODE = 'responsiblePostCode';
public const RESPONSIBLE_POST_CODE = 'responsiblePostCode';
/** @var string */
private const RESPONSIBLE_TOWN = 'responsibleTown';
public const RESPONSIBLE_TOWN = 'responsibleTown';
/** @var string */
private const RESPONSIBLE_COUNTRY = 'responsibleCountry';
public const RESPONSIBLE_COUNTRY = 'responsibleCountry';
/** @var string */
private const RESPONSIBLE_EMAIL = 'responsibleEmail';
public const RESPONSIBLE_EMAIL = 'responsibleEmail';
/** @var string */
private const RESPONSIBLE_PHONE = 'responsiblePhoneNo';
public const RESPONSIBLE_PHONE = 'responsiblePhoneNo';

/**
* Registers item data fields for use in the ShopBuilder.
Expand Down
Loading

0 comments on commit 0ae02f2

Please sign in to comment.