-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3607 from plentymarkets/test/inline_text
feat: eu responsible text alignment
- Loading branch information
Showing
9 changed files
with
288 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/Builders/EuManufacturer/Abstracts/AbstractEuManufacturerBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
40
src/Builders/EuManufacturer/Address/DetailedAddressBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
50
src/Builders/EuManufacturer/Address/GeneralAddressBuilder.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.