Skip to content

Commit

Permalink
Add api configuration for Product and ProductTranslation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomanhez committed Mar 12, 2020
1 parent 7f5b0ec commit bdade86
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Client/ApiPlatformClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function addRequestData(string $key, $value): void

public function addCompoundRequestData(array $data): void
{
$this->request['body'] = array_replace_recursive($this->request['body'], $data);
$this->request['body'] = array_merge_recursive($this->request['body'], $data);
}

public function updateRequestData(array $data): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function iRenameItToIn(string $name, string $language): void
*/
public function iSetItsSlugTo(?string $slug = null, $language = 'en_US'): void
{
$data = ['translations' => [$language => ['locale' => $language, 'slug' => $slug]]];
$data = ['translations' => [$language => ['slug' => $slug]]];

$this->client->addCompoundRequestData($data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,25 @@
<attribute>product:read</attribute>
</attribute>
</attribute>
<attribute name="validation_groups">sylius</attribute>

<collectionOperations />
<collectionOperations>
<collectionOperation name="get" />
<collectionOperation name="post">
<attribute name="denormalization_context">
<attribute name="groups">product:create</attribute>
</attribute>
</collectionOperation>
</collectionOperations>

<itemOperations>
<itemOperation name="get" />
</itemOperations>

<property name="id" identifier="true" writable="false" />
<property name="id" identifier="false" writable="false" />
<property name="code" identifier="true" required="true" />
<property name="createdAt" writable="false" />
<property name="updatedAt" writable="false" />
<property name="translations" readable="true" writable="true" />
</resource>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" ?>

<resources xmlns="https://api-platform.com/schema/metadata"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.0.xsd">

<resource
class="%sylius.model.product_translation.class%"
shortName="ProductTranslation"
>
<attribute name="validation_groups">sylius</attribute>
<collectionOperations />
<itemOperations>
<itemOperation name="get" />
</itemOperations>
<property name="id" identifier="true" writable="false" />
<property name="name" identifier="false" required="true" />
<property name="locale" identifier="false" required="true" />
<property name="slug" identifier="false" required="true" />
<property name="description" identifier="false" required="false" />
<property name="metaKeywords" identifier="false" required="false" />
<property name="metaDescription" identifier="false" required="false" />
<property name="shortDescription" identifier="false" required="false" />
</resource>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,20 @@
<attribute name="id">
<group>product:read</group>
</attribute>
<attribute name="code">
<group>product:read</group>
<group>product:create</group>
</attribute>
<attribute name="createdAt">
<group>product:read</group>
</attribute>
<attribute name="updatedAt">
<group>product:read</group>
</attribute>
<attribute name="translations">
<group>product:read</group>
<group>product:create</group>
<group>product:update</group>
</attribute>
</class>
</serializer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" ?>

<serializer xmlns="http://symfony.com/schema/dic/serializer-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd">

<class name="Sylius\Component\Product\Model\ProductTranslation">
<attribute name="id">
<group>product:read</group>
</attribute>
<attribute name="name">
<group>product:read</group>
<group>product:create</group>
<group>product:update</group>
</attribute>
<attribute name="locale">
<group>product:create</group>
<group>product:update</group>
</attribute>
<attribute name="slug">
<group>product:create</group>
<group>product:read</group>
</attribute>
</class>

</serializer>

0 comments on commit bdade86

Please sign in to comment.