Skip to content

Commit 8153b31

Browse files
authored
Merge pull request #7 from pptasinski-bitbag/release-candidate
Release candidate
2 parents ebe6fec + 4c7ab49 commit 8153b31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+535
-176
lines changed

Diff for: .travis.yml

-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ dist: trusty
55
sudo: false
66

77
php:
8-
- '7.2'
98
- '7.3'
109

1110
cache:
@@ -67,10 +66,6 @@ before_script:
6766

6867
script:
6968
- composer validate --strict
70-
- vendor/bin/phpstan analyse -c phpstan.neon -l max src/
71-
72-
- vendor/bin/phpunit
73-
- vendor/bin/phpspec run
7469
- vendor/bin/behat --strict -vvv --no-interaction || vendor/bin/behat --strict -vvv --no-interaction --rerun
7570

7671
after_failure:

Diff for: README.md

+94-32
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
<h1 align="center">
22
<a href="http://bitbag.shop" target="_blank">
3-
<img src="doc/logo.jpeg" width="55%" />
3+
<img src="doc/logo.png" width="55%" alt="BitBag" />
44
</a>
55
<br />
66
<a href="https://packagist.org/packages/bitbag/product-bundle-plugin" title="License" target="_blank">
7-
<img src="https://img.shields.io/packagist/l/bitbag/product-bundle-plugin.svg" />
7+
<img src="https://img.shields.io/packagist/l/bitbag/product-bundle-plugin.svg" alt="License" />
88
</a>
99
<a href="https://packagist.org/packages/bitbag/product-bundle-plugin" title="Total Downloads" target="_blank">
10-
<img src="https://poser.pugx.org/bitbag/product-bundle-plugin/downloads" />
10+
<img src="https://poser.pugx.org/bitbag/product-bundle-plugin/downloads" alt="Total downloads"/>
1111
</a>
12-
12+
<p>
13+
<a href="https://sylius.com/plugins/" target="_blank">
14+
<img src="https://sylius.com/assets/badge-approved-by-sylius.png" width="85" alt="Approved by Sylius">
15+
</a>
16+
</p>
1317
</h1>
1418

1519
## About us
1620

17-
At BitBag we do believe in open source. However, we are able to do it just beacuse of our awesome clients, who are kind enough to share some parts of our work with the community. Therefore, if you feel like there is a possibility for us working together, feel free to reach us out. You will find out more about our professional services, technologies and contact details at https://bitbag.io/.
21+
At BitBag we do believe in open source. However, we are able to do it just because of our awesome clients, who are kind enough to share some parts of our work with the community. Therefore, if you feel like there is a possibility for us working together, feel free to reach us out. You will find out more about our professional services, technologies and contact details at https://bitbag.io/.
1822

1923
## Overview
2024

@@ -28,7 +32,7 @@ This plugin allows you to create new products by bundling existing products toge
2832
composer require bitbag/product-bundle-plugin
2933
```
3034

31-
1. Add plugin dependencies to your `config/bundles.php` file:
35+
2. Add plugin dependencies to your `config/bundles.php` file:
3236

3337
```php
3438
return [
@@ -38,7 +42,7 @@ This plugin allows you to create new products by bundling existing products toge
3842
];
3943
```
4044

41-
1. Import required config in your `config/packages/_sylius.yaml` file:
45+
3. Import required config in your `config/packages/_sylius.yaml` file:
4246

4347
```yaml
4448
# config/packages/_sylius.yaml
@@ -49,7 +53,7 @@ This plugin allows you to create new products by bundling existing products toge
4953
- { resource: "@BitBagSyliusProductBundlePlugin/Resources/config/config.yml" }
5054
```
5155
52-
1. Import routing in your `config/routes.yaml` file:
56+
4. Import routing in your `config/routes.yaml` file:
5357
5458
```yaml
5559
@@ -60,38 +64,91 @@ This plugin allows you to create new products by bundling existing products toge
6064
resource: "@BitBagSyliusProductBundlePlugin/Resources/config/routing.yml"
6165
```
6266
63-
1. Extend `Product`(including Doctrine mapping)
67+
5. Extend `Product`(including Doctrine mapping):
6468
6569
```php
66-
<?php
67-
68-
declare(strict_types=1);
70+
<?php
71+
72+
declare(strict_types=1);
6973
70-
namespace App\Entity;
74+
namespace App\Entity\Product;
7175
7276
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundlesAwareInterface;
7377
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundlesAwareTrait;
74-
use Doctrine\ORM\Mapping as ORM;
7578
use Sylius\Component\Core\Model\Product as BaseProduct;
76-
77-
/**
78-
* @ORM\Entity
79-
* @ORM\Table(name="sylius_product")
80-
*/
79+
8180
class Product extends BaseProduct implements ProductBundlesAwareInterface
8281
{
83-
use ProductBundlesAwareTrait;
84-
85-
/**
86-
* @OneToOne(targetEntity="BitBag\SyliusProductBundlePlugin\Entity\ProductBundle", mappedBy="product", cascade={"persist", "remove"})
87-
* @var ProductBundleInterface
88-
**/
89-
protected $productBundle;
90-
91-
82+
use ProductBundlesAwareTrait;
83+
}
9284
```
85+
86+
Mapping (XML):
87+
88+
```xml
89+
<?xml version="1.0" encoding="UTF-8"?>
90+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
91+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
92+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
93+
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
94+
>
95+
<entity name="App\Entity\Product\Product" table="sylius_product">
96+
<one-to-one field="productBundle" target-entity="BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface" mapped-by="product">
97+
<cascade>
98+
<cascade-all/>
99+
</cascade>
100+
</one-to-one>
101+
</entity>
102+
</doctrine-mapping>
103+
```
104+
105+
6. Extend `OrderItem` (including Doctrine mapping):
93106
94-
1. Add configuration for extended product and product variant repository:
107+
```php
108+
<?php
109+
110+
declare(strict_types=1);
111+
112+
namespace App\Entity\Order;
113+
114+
use BitBag\SyliusProductBundlePlugin\Entity\OrderItemInterface;
115+
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItemsAwareTrait;
116+
use Sylius\Component\Core\Model\OrderItem as BaseOrderItem;
117+
118+
class OrderItem extends BaseOrderItem implements OrderItemInterface
119+
{
120+
121+
use ProductBundleOrderItemsAwareTrait;
122+
123+
public function __construct()
124+
{
125+
parent::__construct();
126+
$this->init();
127+
}
128+
129+
}
130+
```
131+
132+
Mapping (XML):
133+
134+
```xml
135+
<?xml version="1.0" encoding="UTF-8"?>
136+
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
137+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
138+
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
139+
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
140+
>
141+
<entity name="App\Entity\Order\OrderItem" table="sylius_order_item">
142+
<one-to-many field="productBundleOrderItems" target-entity="BitBag\SyliusProductBundlePlugin\Entity\ProductBundleOrderItem" mapped-by="orderItem" >
143+
<cascade>
144+
<cascade-all/>
145+
</cascade>
146+
</one-to-many>
147+
</entity>
148+
</doctrine-mapping>
149+
```
150+
151+
7. Add configuration for extended product, order item and product variant repository:
95152
96153
```yaml
97154
# config/packages/_sylius.yaml
@@ -103,10 +160,15 @@ This plugin allows you to create new products by bundling existing products toge
103160
product_variant:
104161
classes:
105162
repository: BitBag\SyliusProductBundlePlugin\Repository\ProductVariantRepository
163+
sylius_order:
164+
resources:
165+
order_item:
166+
classes:
167+
model: App\Entity\Order\OrderItem
106168
107169
```
108170
109-
1. Add 'Create/Bundle' to product grid configuration:
171+
8. Add 'Create/Bundle' to product grid configuration:
110172
111173
```yaml
112174
# config/packages/_sylius.yaml
@@ -125,7 +187,7 @@ This plugin allows you to create new products by bundling existing products toge
125187
126188
```
127189
128-
1. Finish the installation by updating the database schema and installing assets:
190+
9. Finish the installation by updating the database schema and installing assets:
129191
130192
```
131193
$ bin/console doctrine:migrations:diff
@@ -137,7 +199,7 @@ This plugin allows you to create new products by bundling existing products toge
137199
$ composer install
138200
$ cd tests/Application
139201
$ yarn install
140-
$ yarn run gulp
202+
$ yarn build
141203
$ bin/console assets:install public -e test
142204
$ bin/console doctrine:schema:create -e test
143205
$ bin/console server:run 127.0.0.1:8080 -d public -e test

Diff for: behat.yml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ default:
3838
FriendsOfBehat\SymfonyExtension:
3939
bootstrap: tests/Application/config/bootstrap.php
4040
kernel:
41-
class: Tests\Acme\SyliusExamplePlugin\Application\Kernel
41+
class: Tests\BitBag\SyliusProductBundlePlugin\Application\Kernel
4242

4343
FriendsOfBehat\VariadicExtension: ~
4444

Diff for: composer.json

+16-17
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
"description": "Product bundle for Sylius.",
66
"license": "MIT",
77
"require": {
8-
"php": "^7.2",
9-
10-
"sylius/sylius": "^1.4",
8+
"php": "^7.3",
9+
"sylius/sylius": "^1.7",
1110
"symfony/messenger": "^4.3"
1211
},
1312
"require-dev": {
14-
"behat/behat": "^3.4",
13+
"behat/behat": "^3.6.1",
1514
"behat/mink": "^1.7@dev",
1615
"behat/mink-browserkit-driver": "^1.3",
1716
"behat/mink-extension": "^2.2",
@@ -21,19 +20,19 @@
2120
"friends-of-behat/symfony-extension": "^2.0",
2221
"friends-of-behat/variadic-extension": "^1.1",
2322
"lakion/mink-debug-extension": "^1.2.3",
24-
"phpspec/phpspec": "^5.0",
25-
"phpstan/phpstan-doctrine": "^0.10",
26-
"phpstan/phpstan-shim": "^0.10",
27-
"phpstan/phpstan-webmozart-assert": "^0.10",
28-
"phpunit/phpunit": "^6.5",
29-
"sensiolabs/security-checker": "^5.0",
30-
"sylius-labs/coding-standard": "^2.0",
31-
"symfony/browser-kit": "^3.4|^4.1",
32-
"symfony/debug-bundle": "^3.4|^4.1",
33-
"symfony/dotenv": "^4.2",
34-
"symfony/intl": "^3.4|^4.1",
35-
"symfony/web-profiler-bundle": "^3.4|^4.1",
36-
"symfony/web-server-bundle": "^3.4|^4.1"
23+
"phpspec/phpspec": "^6.0",
24+
"phpstan/phpstan-doctrine": "^0.12",
25+
"phpstan/phpstan": "^0.12",
26+
"phpstan/phpstan-webmozart-assert": "^0.12",
27+
"phpunit/phpunit": "^7.0",
28+
"sensiolabs/security-checker": "^6.0",
29+
"sylius-labs/coding-standard": "^3.0",
30+
"symfony/browser-kit": "^4.4",
31+
"symfony/debug-bundle": "^4.4",
32+
"symfony/dotenv": "^4.4",
33+
"symfony/intl": "^4.4",
34+
"symfony/web-profiler-bundle": "^4.4",
35+
"symfony/web-server-bundle": "^4.4"
3736
},
3837
"conflict": {
3938
"symfony/symfony": "4.1.8",

Diff for: doc/logo.png

34.6 KB
Loading

Diff for: features/having_bundled_product_in_store.feature

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@bundled_product
2+
Feature: Having a product in store which is a bundle of other products
3+
I want to be able to add bundled product to cart
4+
5+
Background:
6+
Given the store operates on a single channel in "United States"
7+
And the store has locale en_US
8+
9+
@ui
10+
Scenario: Adding a product to cart
11+
Given I am a logged in customer
12+
And the store has a product "Jack Daniels Gentleman" priced at "$10.00"
13+
And the store has a product "Johny Walker Black" priced at "$10.00"
14+
And the store has bundled product "Whiskey double pack" priced at "$18.00" which contains "Jack Daniels Gentleman" and "Johny Walker Black"
15+
And all store products appear under a main taxonomy
16+
Then I added product "Whiskey double pack" to the cart
17+
And I should be on my cart summary page
18+
And there should be one item in my cart

Diff for: phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ includes:
44

55
parameters:
66
reportUnmatchedIgnoredErrors: false
7+
checkMissingIterableValueType: false
78

89
excludes_analyse:
910
# Makes PHPStan crash

Diff for: src/Command/AddProductBundleItemToCartCommand.php

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace BitBag\SyliusProductBundlePlugin\Command;
46

57
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleItemInterface;

Diff for: src/Command/AddProductBundleToCartCommand.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace BitBag\SyliusProductBundlePlugin\Command;
46

7+
use BitBag\SyliusProductBundlePlugin\Entity\OrderItemInterface;
58
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleItemInterface;
69
use BitBag\SyliusProductBundlePlugin\Entity\ProductInterface;
7-
use Sylius\Component\Core\Model\OrderInterface;
8-
use Sylius\Component\Core\Model\OrderItemInterface;
10+
use Sylius\Component\Order\Model\OrderInterface;
911

1012
final class AddProductBundleToCartCommand
1113
{

0 commit comments

Comments
 (0)