Skip to content

Commit bf9b07c

Browse files
authored
Merge branch 'master' into https-ssl-authentication
2 parents 9c42e91 + a42e3ed commit bf9b07c

Some content is hidden

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

55 files changed

+1724
-8563
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ dist: xenial
55
sudo: false
66

77
php:
8-
- 7.2.26
98
- 7.3
109

1110
cache:

README.md

Lines changed: 172 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ Please also check [Sylius Documentation](https://docs.sylius.com/en/latest/) and
4141
Depending on your preferences, the plugin can also fully replace [VSF API](https://github.com/DivanteLtd/vue-storefront-api/) - you will only need VSF front app if you choose so.
4242
Sylius ShopBundle is also no longer needed as Vue Storefront will be your new ... Storefront. :)
4343

44+
### Supported versions
45+
46+
| Plugin version | Sylius version | Supported VSF version |
47+
|:--------------------:|:--------------:|:---------------------:|
48+
| v2.0.0 | 1.8 | 1.12.2 |
49+
| v1.0.0-beta.1 | 1.6 | 1.11.4 |
50+
51+
4452
## Vue Storefront + Sylius Demo
4553

4654
We've created a demo app that showcases usage of this plugin. Visit [vsf.bitbag.shop](https://vsf.bitbag.shop) to check it out!
@@ -56,10 +64,10 @@ Please also check [Vue Storefront requirements](https://docs.vuestorefront.io/gu
5664

5765
| Package | Version |
5866
|:-------------:|:--------------:|
59-
| PHP | 7.3 (>= 7.2) |
67+
| PHP | 7.4 (>= 7.3) |
6068
| MySQL | 8.0.x (>= 5.7)|
6169
| Elasticsearch | 6.8.x |
62-
| Vue Storefront| 1.11 |
70+
| Vue Storefront| 1.12 |
6371

6472
**Important note**
6573
Please inspect files stored in `tests/Application` directory (especially `config` subdirectory)
@@ -73,10 +81,10 @@ Please refer to [Sylius Documentation - How to disable Sylius shop?](https://doc
7381
First, add this plugin as dependency to your Sylius project.
7482

7583
```
76-
$ composer require bitbag/vuestorefront-plugin
84+
$ composer require bitbag/vuestorefront-plugin:v1.0.0-beta.1
7785
```
7886

79-
Add plugin to `config/bundles.php`:
87+
Add the plugin to `config/bundles.php` (if it's not there already):
8088

8189
```
8290
return [
@@ -129,12 +137,25 @@ Then set value of `JWT_PASSPHRASE` environment variable with passphrase that you
129137

130138
---
131139

132-
Now it is time to edit `config/packages/security.yaml` file.
140+
Next step is to add a following line to the end of the `imports` section in your `config/packages/_sylius.yaml`:
141+
142+
```
143+
- { resource: "@SyliusVueStorefrontPlugin/Resources/config/config.yaml" }
144+
```
145+
146+
It's needed to load some plugin configuration.
147+
148+
---
149+
150+
Now it is needed to edit `config/packages/security.yaml` file.
133151

134-
Add line below to `parameters` at the top of the file:
135-
`bitbag.vue_storefront.security.regex: "^/vsbridge"`
152+
Add a line below to `parameters` key at the top of the file:
153+
154+
```
155+
bitbag.vue_storefront.security.regex: "^/vsbridge"
156+
```
136157

137-
Add code below to `security -> firewall` part:
158+
Add a code below to the top of `security -> firewalls` key (an order is really important there):
138159

139160
```
140161
vs_bridge_user_login:
@@ -161,8 +182,38 @@ Add code below to `security -> firewall` part:
161182
- lexik_jwt_authentication.jwt_token_authenticator
162183
```
163184

164-
Add line below to `security -> access_control` part:
165-
`- { path: "%bitbag.vue_storefront.security.regex%/user/login", role: IS_AUTHENTICATED_ANONYMOUSLY }`
185+
So it should look like this:
186+
187+
```
188+
firewalls:
189+
vs_bridge_user_login:
190+
pattern: "%bitbag.vue_storefront.security.regex%/user/login"
191+
stateless: true
192+
anonymous: true
193+
provider: sylius_shop_user_provider
194+
json_login:
195+
provider: sylius_shop_user_provider
196+
check_path: /vsbridge/user/login
197+
password_path: password
198+
success_handler: bitbag_sylius_vue_storefront_plugin.lexik_jwt_authentication.handler.authentication_success
199+
failure_handler: bitbag_sylius_vue_storefront_plugin.lexik_jwt_authentication.handler.authentication_failure
200+
require_previous_session: false
201+
202+
vs_bridge:
203+
pattern: "%bitbag.vue_storefront.security.regex%"
204+
stateless: true
205+
anonymous: true
206+
provider: sylius_shop_user_provider
207+
guard:
208+
provider: sylius_shop_user_provider
209+
authenticators:
210+
- lexik_jwt_authentication.jwt_token_authenticator
211+
```
212+
213+
Afterwards add a line below to `security -> access_control` part:
214+
```
215+
- { path: "%bitbag.vue_storefront.security.regex%/user/login", role: IS_AUTHENTICATED_ANONYMOUSLY }
216+
```
166217

167218
---
168219

@@ -173,6 +224,8 @@ sylius_vue_storefront_plugin:
173224
resource: "@SyliusVueStorefrontPlugin/Resources/config/routing.yaml"
174225
```
175226

227+
to load configuration of all routes for API endpoints.
228+
176229
---
177230

178231
Create new file `gesdinet_jwt_refresh_token.yaml` (or name it however you like) inside `config/packages` directory and paste inside it:
@@ -185,7 +238,7 @@ gesdinet_jwt_refresh_token:
185238
```
186239
---
187240

188-
Paste lines below inside `config/packages/lexik_jwt_authentication.yaml`:
241+
Replace content of your `config/packages/lexik_jwt_authentication.yaml` file with the following configuration:
189242

190243
```
191244
lexik_jwt_authentication:
@@ -201,9 +254,81 @@ lexik_jwt_authentication:
201254

202255
---
203256

257+
Afterwards add:
258+
259+
```
260+
translator: { fallbacks: ["%locale%"] }
261+
```
262+
263+
under your `framework` key in `config/packages/framework.yaml` so it should look like this afterwards:
264+
265+
```
266+
framework:
267+
translator: { fallbacks: ["%locale%"] }
268+
secret: '%env(APP_SECRET)%'
269+
form: true
270+
csrf_protection: true
271+
templating: { engines: ["twig"] }
272+
session:
273+
handler_id: ~
274+
```
275+
---
276+
277+
Set content of your `config/fos_elastica.yaml` to the following:
278+
279+
```
280+
imports:
281+
- { resource: "@SyliusVueStorefrontPlugin/Resources/config/indexes/attribute.yaml" }
282+
- { resource: "@SyliusVueStorefrontPlugin/Resources/config/indexes/category.yaml" }
283+
- { resource: "@SyliusVueStorefrontPlugin/Resources/config/indexes/product.yaml" }
284+
285+
fos_elastica:
286+
clients:
287+
default: { host: '%env(ELASTICSEARCH_HOST)%', port: '%env(ELASTICSEARCH_PORT)%' }
288+
```
289+
290+
---
291+
292+
Add a following rule to `fos_rest.format_listener.rules` in your `config/packages/fos_rest.yaml`
293+
294+
```
295+
- { path: '^/vsbridge/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true }
296+
```
297+
298+
For example the file should look like this afterwards:
299+
300+
```
301+
fos_rest:
302+
exception: true
303+
view:
304+
formats:
305+
json: true
306+
xml: true
307+
empty_content: 204
308+
format_listener:
309+
rules:
310+
- { path: '^/api/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true }
311+
- { path: '^/vsbridge/.*', priorities: ['json', 'xml'], fallback_format: json, prefer_extension: true }
312+
- { path: '^/', stop: true }
313+
```
314+
315+
---
316+
Go to your `src/Entity/Order/OrderItem.php` file and make it to extend the `OrderItem` entity from our plugin.
317+
318+
Change:
319+
```
320+
use Sylius\Component\Core\Model\OrderItem as BaseOrderItem;
321+
```
322+
to:
323+
```
324+
use BitBag\SyliusVueStorefrontPlugin\Sylius\Entity\Order\OrderItem as BaseOrderItem;
325+
```
326+
327+
---
328+
204329
Copy `etc/vsf-config/local.json` file from this repository to `config/local.json` of Vue Storefront project directory.
205330
In that file you only need to replace every occurence of `<insert-your-hostname>` with URL of your store.
206-
You don't have to change anything else as sensible defaults are provided by us, that are proven to work in Vue Storefront v1.11.
331+
You don't have to change anything else as sensible defaults are provided by us, that are proven to work in Vue Storefront v1.12.
207332
If your configuration settings differ from defaults provided with the plugin and you run into problems don't hesitate to create issue on GitHub or contact us directly at [email protected].
208333

209334
## Architecture
@@ -256,6 +381,41 @@ $ php bin/console fos:elastica:populate
256381

257382
to populate Elasticsearch indexes and let refresher contained within the plugin to automatically update the data in ES in real time.
258383

384+
### Known issues
385+
386+
#### Translatable trait error during loading fixtures
387+
388+
<img src="doc/fixtures_error.png"></img>
389+
390+
In case of this error - to be able to load the fixtures, go to the `vendor/bitbag/vuestorefront-plugin/src/Resources/config/indexes/product.yaml` file and comment last line in there (the `defer:true` one).
391+
392+
Then clear the cache, load fixtures and uncomment this line afterwards.
393+
394+
#### Getting 500 error related to taxa (`taxons`)
395+
If you see something like this for example in your admin panel:
396+
```
397+
{
398+
"result": "Variable \"taxons\" does not exist.",
399+
"code": 500
400+
}
401+
```
402+
it means you are using invalid version of `doctrine/inflector` package.
403+
404+
To fix it add a following block into your `composer.json` file:
405+
```
406+
"conflict": {
407+
"doctrine/inflector": "^1.4"
408+
},
409+
```
410+
Make sure that
411+
```
412+
"bitbag/vuestorefront-plugin": "v1.0.0-beta.1"
413+
```
414+
is present in `require` section in your `composer.json` file and then run:
415+
```
416+
$ composer update
417+
```
418+
259419
## Extending the plugin
260420

261421
### Extending requests, commands/queries

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
"description": "BitBag VueStorefront bridge for Sylius.",
66
"license": "MIT",
77
"require": {
8-
"php": "^7.2",
8+
"php": "^7.3",
99
"ext-json": "*",
1010
"friendsofsymfony/elastica-bundle": "^5.1",
1111
"ruflin/elastica": "^6.1",
12-
"sylius/sylius": "^1.6",
12+
"sylius/sylius": "^1.8",
1313
"nelmio/cors-bundle": "^1.5",
1414
"symfony/messenger": "^4.4",
1515
"lexik/jwt-authentication-bundle": "^2.6",
1616
"gesdinet/jwt-refresh-token-bundle": "^0.8",
1717
"imagine/imagine": "^1.2",
18-
"symfony/serializer": "^4.4",
18+
"symfony/serializer": "^5.0",
1919
"symfony/property-info": "^4.4"
2020
},
2121
"suggest": {

doc/fixtures_error.png

23.7 KB
Loading

spec/Command/Cart/CreateCartSpec.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,11 @@
1717

1818
final class CreateCartSpec extends ObjectBehavior
1919
{
20-
public function let(): void
21-
{
22-
$this->beConstructedWith('token');
23-
}
24-
2520
function it_is_initializable(): void
2621
{
2722
$this->shouldHaveType(CreateCart::class);
2823
}
2924

30-
function it_allows_to_access_token_via_getter(): void
31-
{
32-
$this->token()->shouldReturn('token');
33-
}
34-
3525
function it_allows_to_set_and_access_cart_id(): void
3626
{
3727
$this->setCartId('cart-id');

0 commit comments

Comments
 (0)