-
Notifications
You must be signed in to change notification settings - Fork 23
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 #182 from synolia/feature/import-text-asset-attribute
Import "text" type asset attributes
- Loading branch information
Showing
9 changed files
with
192 additions
and
76 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/Builder/Asset/Attribute/TextAssetAttributeValueBuilder.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Synolia\SyliusAkeneoPlugin\Builder\Asset\Attribute; | ||
|
||
use Synolia\SyliusAkeneoPlugin\Provider\Asset\AkeneoAssetAttributePropertiesProviderInterface; | ||
use Synolia\SyliusAkeneoPlugin\Provider\Asset\AssetAttributeTypeMatcherProviderInterface; | ||
use Synolia\SyliusAkeneoPlugin\TypeMatcher\Asset\Attribute\TextAssetAttributeTypeMatcher; | ||
|
||
final class TextAssetAttributeValueBuilder implements AssetAttributeValueBuilderInterface | ||
{ | ||
public function __construct( | ||
private AssetAttributeTypeMatcherProviderInterface $assetAttributeTypeMatcherProvider, | ||
private AkeneoAssetAttributePropertiesProviderInterface $akeneoAssetAttributePropertiesProvider, | ||
) { | ||
} | ||
|
||
public function support(string $assetFamilyCode, string $attributeCode): bool | ||
{ | ||
return $this->assetAttributeTypeMatcherProvider->match($this->akeneoAssetAttributePropertiesProvider->getType($assetFamilyCode, $attributeCode)) instanceof TextAssetAttributeTypeMatcher; | ||
} | ||
|
||
public function build( | ||
string $assetFamilyCode, | ||
string $assetCode, | ||
?string $locale, | ||
?string $scope, | ||
mixed $value, | ||
): array { | ||
return ['value' => $value]; | ||
} | ||
} |
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
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
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
33 changes: 33 additions & 0 deletions
33
src/TypeMatcher/Asset/Attribute/TextAssetAttributeTypeMatcher.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Synolia\SyliusAkeneoPlugin\TypeMatcher\Asset\Attribute; | ||
|
||
use Sylius\Component\Attribute\AttributeType\TextAttributeType; | ||
use Synolia\SyliusAkeneoPlugin\Builder\Asset\Attribute\TextAssetAttributeValueBuilder; | ||
|
||
final class TextAssetAttributeTypeMatcher implements AssetAttributeTypeMatcherInterface | ||
{ | ||
private const SUPPORTED_TYPE = 'text'; | ||
|
||
public function getType(): string | ||
{ | ||
return TextAttributeType::TYPE; | ||
} | ||
|
||
public function support(string $akeneoType): bool | ||
{ | ||
return self::SUPPORTED_TYPE === $akeneoType; | ||
} | ||
|
||
public function getBuilder(): string | ||
{ | ||
return TextAssetAttributeValueBuilder::class; | ||
} | ||
|
||
public function getTypeClassName(): string | ||
{ | ||
return TextAttributeType::class; | ||
} | ||
} |
Oops, something went wrong.