Skip to content

Commit

Permalink
Fix installing plugin on clean Sylius Standard application
Browse files Browse the repository at this point in the history
  • Loading branch information
senghe committed Oct 18, 2022
1 parent ab9aa96 commit e6940d5
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 36 deletions.
33 changes: 27 additions & 6 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,32 @@
repository: BitBag\SyliusVueStorefront2Plugin\Doctrine\Repository\TaxonRepository
```
9. If you're extending Sylius' `ProductAttributeValue` entity, please extend it by `BitBag\SyliusVueStorefront2Plugin\Model\ProductAttributeValue`.
9. If you're extending Sylius' `ProductAttributeValue` entity, please use our trait inside: `BitBag\SyliusVueStorefront2Plugin\Model\ProductAttributeValueTrait`.
10. Import routing in routes.yaml
10. Please add the Doctrine mapping configuration into your project:
```yml
bitbag_sylius_vue_storefront2_plugin:
resource: "@BitBagSyliusVueStorefront2Plugin/Resources/config/routing.yml"
```
```xml
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
>
<entity name="Tests\BitBag\SyliusVueStorefront2Plugin\Entity\ProductAttributeValue" table="sylius_product_attribute_value">
<indexes>
<index name="locale_code" columns="locale_code" />
</indexes>
</entity>
</doctrine-mapping>
```
Please change the `name` attribute to fit your entity name. If you've already the `ProductAttributeValue` mapping in your project, just add there the `<index>` part of mapping above.
11. Import routing in routes.yaml
```yml
bitbag_sylius_vue_storefront2_plugin:
resource: "@BitBagSyliusVueStorefront2Plugin/Resources/config/routing.yml"
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
namespace BitBag\SyliusVueStorefront2Plugin\Model;

use Sylius\Component\Attribute\Model\AttributeInterface;
use Sylius\Component\Product\Model\ProductAttributeValue as BaseAttributeValue;
use Webmozart\Assert\Assert;

class ProductAttributeValue extends BaseAttributeValue
trait ProductAttributeValueTrait
{
/** @return mixed|null */
public function getValue()
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/api_resources/Product.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ We are hiring developers from all over the world. Join us and start your new, ex
<property name="reviews" required="false" />
<property name="options" required="false" />
<property name="attributes" required="false">
<subresource resourceClass="BitBag\SyliusVueStorefront2Plugin\Model\ProductAttributeValue" />
<subresource resourceClass="%sylius.model.product_attribute_value.class%" />
</property>
<property name="channels" required="false" />
<property name="images" required="false" />
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/api_resources/ProductAttributeValue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ We are hiring developers from all over the world. Join us and start your new, ex
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="BitBag\SyliusVueStorefront2Plugin\Model\ProductAttributeValue" shortName="ProductAttributeValue">
<resource class="%sylius.model.product_attribute_value.class%" shortName="ProductAttributeValue">
<graphql>
<operation name="item_query" />
<operation name="collection_query">
Expand Down
22 changes: 0 additions & 22 deletions src/Resources/doctrine/model/ProductAttributeValue.orm.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/Resources/serialization/ProductAttributeValue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ We are hiring developers from all over the world. Join us and start your new, ex
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="BitBag\SyliusVueStorefront2Plugin\Model\ProductAttributeValue">
<class name="Sylius\Component\Product\Model\ProductAttributeValue">
<attribute name="stringValue">
<group>shop:product:read</group>
</attribute>
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/config/packages/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sylius_attribute:
subject: Sylius\Component\Core\Model\Product
attribute_value:
classes:
model: BitBag\SyliusVueStorefront2Plugin\Model\ProductAttributeValue
model: Tests\BitBag\SyliusVueStorefront2Plugin\Entity\ProductAttributeValue

sylius_taxonomy:
resources:
Expand Down
10 changes: 8 additions & 2 deletions tests/Application/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ doctrine:
auto_generate_proxy_classes: '%kernel.debug%'
auto_mapping: true
mappings:
GraphqQL:
SyliusVueStorefront2Plugin:
is_bundle: false
type: xml
dir: '%kernel.project_dir%/../../src/Resources/doctrine/model'
prefix: 'BitBag\SyliusVueStorefront2Plugin\Model'
alias: BitBag\SyliusGraphqlPlugin
alias: BitBag\SyliusVueStorefront2Plugin
TestsVueStorefront2Plugin:
is_bundle: false
type: xml
dir: '%kernel.project_dir%/src/Resources/config/doctrine'
prefix: 'Tests\BitBag\SyliusVueStorefront2Plugin\Entity'
alias: Tests\BitBag\SyliusVueStorefront2Plugin
13 changes: 13 additions & 0 deletions tests/Application/src/Entity/ProductAttributeValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Tests\BitBag\SyliusVueStorefront2Plugin\Entity;

use BitBag\SyliusVueStorefront2Plugin\Model\ProductAttributeValueTrait;
use Sylius\Component\Product\Model\ProductAttributeValue as BaseProductAttributeValue;

class ProductAttributeValue extends BaseProductAttributeValue
{
use ProductAttributeValueTrait;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
>
<entity name="Tests\BitBag\SyliusVueStorefront2Plugin\Entity\ProductAttributeValue" table="sylius_product_attribute_value">
<indexes>
<index name="locale_code" columns="locale_code" />
</indexes>
</entity>
</doctrine-mapping>

0 comments on commit e6940d5

Please sign in to comment.