-
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 #48 from flagbit/akeneo4
Update bundle for Akeneo 4.0
- Loading branch information
Showing
29 changed files
with
484 additions
and
309 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
build: | ||
nodes: | ||
analysis: | ||
environment: | ||
apt_packages: | ||
- libmagickwand-dev | ||
- libmagickcore-dev | ||
php: | ||
version: 7.3 | ||
pecl_extensions: | ||
- apcu | ||
- imagick | ||
- zip |
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
24 changes: 24 additions & 0 deletions
24
...bleAttributeBundle/Component/Product/Completeness/MaskItemGenerator/TableMaskItemSpec.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,24 @@ | ||
<?php | ||
|
||
namespace spec\Flagbit\Bundle\TableAttributeBundle\Component\Product\Completeness\MaskItemGenerator; | ||
|
||
use Flagbit\Bundle\TableAttributeBundle\Component\Product\Completeness\MaskItemGenerator\TableMaskItem; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class TableMaskItemSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(TableMaskItem::class); | ||
} | ||
|
||
public function it_masks_for_raw_value() | ||
{ | ||
$this->forRawValue('a', 'b', 'c', 'd')->shouldBe(['a-b-c']); | ||
} | ||
|
||
public function it_supports_attribute_types() | ||
{ | ||
$this->supportedAttributeTypes()->shouldBe(['flagbit_catalog_table']); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...bit/Bundle/TableAttributeBundle/Component/Product/Factory/Value/TableValueFactorySpec.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,74 @@ | ||
<?php | ||
|
||
namespace spec\Flagbit\Bundle\TableAttributeBundle\Component\Product\Factory\Value; | ||
|
||
use Akeneo\Pim\Enrichment\Component\Product\Value\ScalarValue; | ||
use Akeneo\Pim\Structure\Component\Query\PublicApi\AttributeType\Attribute; | ||
use Akeneo\Tool\Component\StorageUtils\Exception\InvalidPropertyTypeException; | ||
use EmptyIterator; | ||
use Flagbit\Bundle\TableAttributeBundle\Component\Product\Factory\Value\TableValueFactory; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class TableValueFactorySpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(TableValueFactory::class); | ||
} | ||
|
||
public function it_creates_scopable_and_localizable_table_value() | ||
{ | ||
$attribute = $this->createAttribute(true, true); | ||
|
||
$this->createByCheckingData($attribute, 'channelCode', 'de_DE', 'data') | ||
->shouldBeLike(ScalarValue::scopableLocalizableValue('code', 'data', 'channelCode', 'de_DE')); | ||
} | ||
|
||
public function it_creates_scopable_table_value() | ||
{ | ||
$attribute = $this->createAttribute(true, false); | ||
|
||
$this->createByCheckingData($attribute, 'channelCode', null, 'data') | ||
->shouldBeLike(ScalarValue::scopableValue('code', 'data', 'channelCode')); | ||
} | ||
|
||
public function it_creates_localizable_table_value() | ||
{ | ||
$attribute = $this->createAttribute(false, true); | ||
|
||
$this->createByCheckingData($attribute, null, 'de_DE', 'data') | ||
->shouldBeLike(ScalarValue::localizableValue('code', 'data', 'de_DE')); | ||
} | ||
|
||
public function it_creates_table_value() | ||
{ | ||
$attribute = $this->createAttribute(false, false); | ||
|
||
$this->createByCheckingData($attribute, null, null, 'data') | ||
->shouldBeLike(ScalarValue::value('code', 'data')); | ||
} | ||
|
||
public function it_throws_exception_on_nonscalar_data() | ||
{ | ||
$attribute = $this->createAttribute(false, false); | ||
|
||
$this->shouldThrow()->during('createByCheckingData', [$attribute, null, null, new EmptyIterator()]); | ||
} | ||
|
||
public function it_throws_exception_on_empty_data() | ||
{ | ||
$attribute = $this->createAttribute(false, false); | ||
|
||
$this->shouldThrow(InvalidPropertyTypeException::class)->during('createByCheckingData', [$attribute, null, null, "\0\n "]); | ||
} | ||
|
||
private function createAttribute(bool $isScopable, bool $isLocalizable): Attribute | ||
{ | ||
return new Attribute('code', 'flagbit_catalog_table', [], $isLocalizable, $isScopable, null, false, 'backend', ['de_DE', 'en_US']); | ||
} | ||
|
||
public function it_supports_attribute_type() | ||
{ | ||
$this->supportedAttributeType()->shouldBe('flagbit_catalog_table'); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/Component/Product/Completeness/MaskItemGenerator/TableMaskItem.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,28 @@ | ||
<?php | ||
|
||
namespace Flagbit\Bundle\TableAttributeBundle\Component\Product\Completeness\MaskItemGenerator; | ||
|
||
use Akeneo\Pim\Enrichment\Component\Product\Completeness\MaskItemGenerator\MaskItemGeneratorForAttributeType; | ||
use Flagbit\Bundle\TableAttributeBundle\AttributeType\TableType; | ||
|
||
class TableMaskItem implements MaskItemGeneratorForAttributeType | ||
{ | ||
public function forRawValue(string $attributeCode, string $channelCode, string $localeCode, $value): array | ||
{ | ||
return [ | ||
sprintf( | ||
'%s-%s-%s', | ||
$attributeCode, | ||
$channelCode, | ||
$localeCode | ||
) | ||
]; | ||
} | ||
|
||
public function supportedAttributeTypes(): array | ||
{ | ||
return [ | ||
TableType::FLAGBIT_CATALOG_TABLE, | ||
]; | ||
} | ||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace Flagbit\Bundle\TableAttributeBundle\Component\Product\Factory\Value; | ||
|
||
use Akeneo\Pim\Enrichment\Component\Product\Factory\Value\ScalarValueFactory; | ||
use Akeneo\Pim\Enrichment\Component\Product\Model\ValueInterface; | ||
use Akeneo\Pim\Structure\Component\Query\PublicApi\AttributeType\Attribute; | ||
use Akeneo\Tool\Component\StorageUtils\Exception\InvalidPropertyTypeException; | ||
use Flagbit\Bundle\TableAttributeBundle\AttributeType\TableType; | ||
|
||
final class TableValueFactory extends ScalarValueFactory | ||
{ | ||
public function createByCheckingData( | ||
Attribute $attribute, | ||
?string $channelCode, | ||
?string $localeCode, | ||
$data | ||
): ValueInterface { | ||
if (!is_scalar($data) || (is_string($data) && '' === trim($data))) { | ||
throw InvalidPropertyTypeException::stringExpected( | ||
$attribute->code(), | ||
static::class, | ||
$data | ||
); | ||
} | ||
|
||
return parent::createWithoutCheckingData($attribute, $channelCode, $localeCode, $data); | ||
} | ||
|
||
public function supportedAttributeType(): string | ||
{ | ||
return TableType::FLAGBIT_CATALOG_TABLE; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="flagbit_catalog_table.factory.value.table" class="%pim_catalog.factory.value.scalar.class%" | ||
<service id="flagbit_table_attribute.factory.value.table" class="Flagbit\Bundle\TableAttributeBundle\Component\Product\Factory\Value\TableValueFactory" | ||
public="false"> | ||
<tag name="pim_catalog.factory.value"/> | ||
<argument>%pim_catalog.entity.value.scalar.class%</argument> | ||
<argument>flagbit_catalog_table</argument> | ||
<tag name="akeneo.pim.enrichment.factory.product_value"/> | ||
</service> | ||
</services> | ||
</container> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
@import "./web/bundles/flagbittableattribute/less/tableattribute.less"; | ||
@import "./public/bundles/flagbittableattribute/less/tableattribute.less"; |
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
Oops, something went wrong.