Skip to content

Commit

Permalink
Plugin development (#9)
Browse files Browse the repository at this point in the history
* Agreement extended body can be null

* Fix GH actions

* Fix GH actions

* Add parent autocomplete function

* Fix

* Namespace fix

* Add OS header

* Agreement services cleaning

* Add agreement adding/editing template

* Add sylius 1.11 support

* GHA fix

* Fix 404 error after not accepting the required agreement

* Add AutocompleteChoiceType test

* Add Form/Type/Admin phpunit tests

* Add Form/Type/Shop phpunit tests

* Add agreement subscriber phpunit test

* Function name fix & typo fix & change coding standard

* Bug fix

* Phpstan fix

* Add behat tests for user registration with required agreement

* Fix composer dependencies

* Move translation to the proper place

* Change composer plugin name

* Fix translation path

* Readme update

* Fix infinity page reloading when set parent same as agreement (validator)

* Fix phpstan

* ecs fix

* Fixed typo and changed snake case function names

* Change behat declarations from yml files to xml

* behat fix

* Fix behat
  • Loading branch information
liszkapawel authored Mar 31, 2022
1 parent 55e0b22 commit 903e5af
Show file tree
Hide file tree
Showing 113 changed files with 1,987 additions and 757 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches-ignore:
- 'dependabot/**'
pull_request: ~
release:
types: [ created ]
schedule:
Expand All @@ -22,14 +21,19 @@ jobs:
matrix:
php: [ "8.0", "7.4" ]
symfony: [ "^4.4", "^5.2" ]
sylius: [ "~1.9.0", "~1.10.0@alpha" ]
node: [ "10.x" ]
sylius: ["~1.9.0", "~1.10.0", "~1.11.0"]
node: [ "14.19" ]
mysql: [ "8.0" ]

exclude:
- php: "8.0"
sylius: "~1.9.0"
- sylius: ~1.9.0
php: 8.0

- sylius: ~1.10.0
symfony: 4.4

- sylius: ~1.11.0
php: 7.4

env:
APP_ENV: test
Expand Down Expand Up @@ -130,14 +134,17 @@ jobs:
run: (cd tests/Application && bin/console doctrine:schema:validate)

- name: Run PHPStan
run: vendor/bin/phpstan analyse -c vendor/bitbag/coding-standard/phpstan.neon -l max src/
run: vendor/bin/phpstan analyse -c vendor/bitbag/coding-standard/phpstan.neon -l 8 src/

- name: Run ECS
run: vendor/bin/ecs check src

- name: Run PHPUnit
run: vendor/bin/phpunit --colors=always

- name: Run Behat
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun

- name: Upload Behat logs
uses: actions/upload-artifact@v2
if: failure()
Expand Down
295 changes: 183 additions & 112 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,112 +1,183 @@
<p align="center">
<a href="https://sylius.com" target="_blank">
<img src="https://demo.sylius.com/assets/shop/img/logo.png" />
</a>
</p>

<h1 align="center">Plugin Skeleton</h1>

<p align="center">Skeleton for starting Sylius plugins.</p>

## Documentation

For a comprehensive guide on Sylius Plugins development please go to Sylius documentation,
there you will find the <a href="https://docs.sylius.com/en/latest/plugin-development-guide/index.html">Plugin Development Guide</a>, that is full of examples.

## Quickstart Installation

1. Run `composer create-project sylius/plugin-skeleton ProjectName`.

2. From the plugin skeleton root directory, run the following commands:

```bash
$ (cd tests/Application && yarn install)
$ (cd tests/Application && yarn build)
$ (cd tests/Application && APP_ENV=test bin/console assets:install public)

$ (cd tests/Application && APP_ENV=test bin/console doctrine:database:create)
$ (cd tests/Application && APP_ENV=test bin/console doctrine:schema:create)
```

To be able to setup a plugin's database, remember to configure you database credentials in `tests/Application/.env` and `tests/Application/.env.test`.
## Usage
### Running plugin tests
- PHPUnit
```bash
vendor/bin/phpunit
```
- PHPSpec
```bash
vendor/bin/phpspec run
```
- Behat (non-JS scenarios)
```bash
vendor/bin/behat --strict --tags="~@javascript"
```
- Behat (JS scenarios)
1. [Install Symfony CLI command](https://symfony.com/download).
2. Start Headless Chrome:
```bash
google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1
```
3. Install SSL certificates (only once needed) and run test application's webserver on `127.0.0.1:8080`:

```bash
symfony server:ca:install
APP_ENV=test symfony server:start --port=8080 --dir=tests/Application/public --daemon
```

4. Run Behat:

```bash
vendor/bin/behat --strict --tags="@javascript"
```

- Static Analysis

- Psalm

```bash
vendor/bin/psalm
```

- PHPStan

```bash
vendor/bin/phpstan analyse -c phpstan.neon -l max src/
```

- Coding Standard

```bash
vendor/bin/ecs check src
```

### Opening Sylius with your plugin

- Using `test` environment:

```bash
(cd tests/Application && APP_ENV=test bin/console sylius:fixtures:load)
(cd tests/Application && APP_ENV=test bin/console server:run -d public)
```

- Using `dev` environment:

```bash
(cd tests/Application && APP_ENV=dev bin/console sylius:fixtures:load)
(cd tests/Application && APP_ENV=dev bin/console server:run -d public)
```
# [![](https://bitbag.io/wp-content/uploads/2022/03/SyliusPocztaPolskaShippingExportPlugin.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_pocztapolska)

# BitBagSyliusAgreementPlugin

----

<p>
<img align="left" src="https://sylius.com/assets/badge-approved-by-sylius.png" width="85">
</p>

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 to work together, feel free to reach out. You will find out more about our professional services, technologies, and contact details at [https://bitbag.io/](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms).

Like what we do? Want to join us? Check out our job listings on our [career page](https://bitbag.io/career/?utm_source=github&utm_medium=referral&utm_campaign=career). Not familiar with Symfony & Sylius yet, but still want to start with us? Join our [academy](https://bitbag.io/pl/akademia?utm_source=github&utm_medium=url&utm_campaign=akademia)!

## Table of Content

***

* [Overview](#overview)
* [Support](#we-are-here-to-help)
* [Installation](#installation)
* [Testing](#testing)
* [About us](#about-us)
* [Community](#community)
* [Demo](#demo)
* [License](#license)
* [Contact](#contact)

# Overview

***

Almost every eCommerce app has to present some content. Managing it is often done via third-party libraries like WordPress, eZ Platform, or a built-in content management system. As Sylius does not have a CMS in the standard platform, we decided to develop our own, which will be as flexible as Sylius. This plugin allows you to add dynamic blocks with images, text or HTML to your storefront, as well as pages and FAQs section.

## We are here to help
This **open-source plugin was developed to help the Sylius community**. If you have any additional questions, would like help with installing or configuring the plugin, or need any assistance with your Sylius project - let us know!

[![](https://bitbag.io/wp-content/uploads/2020/10/button-contact.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms)

## Installation

***

1. Add the plugin to your project using:

```bash
$ composer require bitbag/sylius-agreement-plugin
```

2. Add plugin dependencies to your config/bundles.php file:

```php
return [
...

BitBag\SyliusAgreementPlugin\BitBagSyliusAgreementPlugin::class => ['all' => true],
];
```

3.Add routes to your config/routes.yaml:
```yaml
bitbag_sylius_agreement_plugin:
resource: "@BitBagSyliusAgreementPlugin/Resources/config/routing.yml"
```
4.Add trait to your Customer class:
```php
use AgreementsRequiredTrait;
```

5.[Overwrite](https://symfony.com/doc/3.4/templating/overriding.html) following templates:

- [@SyliusShopBundle/Register/_form.html.twig](/tests/Application/templates/bundles/SyliusShopBundle/Register/_form.html.twig)

Examples are in the package you have downloaded under the path [tests/Application/templates/bundles/*](/tests/Application/templates/bundles/)

## Testing

***

```bash
$ composer install
$ cd tests/Application
$ yarn install
$ yarn build
$ bin/console doctrine:database:create --env=test
$ bin/console doctrine:schema:create --env=test
$ bin/console sylius:fixtures:load --env=test
$ APP_ENV=test symfony server:start --dir=public/
$ cd ../..
$ vendor/bin/behat
$ vendor/bin/phpunit
```

# About us

---

BitBag is a company of people who **love what they do** and do it right. We fulfill the eCommerce technology stack with **Sylius**, Shopware, Akeneo, and Pimcore for PIM, eZ Platform for CMS, and VueStorefront for PWA. Our goal is to provide real digital transformation with an agile solution that scales with the **clients’ needs**. Our main area of expertise includes eCommerce consulting and development for B2C, B2B, and Multi-vendor Marketplaces.</br>
We are advisers in the first place. We start each project with a diagnosis of problems, and an analysis of the needs and **goals** that the client wants to achieve.</br>
We build **unforgettable**, consistent digital customer journeys on top of the **best technologies**. Based on a detailed analysis of the goals and needs of a given organization, we create dedicated systems and applications that let businesses grow.<br>
Our team is fluent in **Polish, English, German and, French**. That is why our cooperation with clients from all over the world is smooth.

**Some numbers from BitBag regarding Sylius:**
- 50+ **experts** including consultants, UI/UX designers, Sylius trained front-end and back-end developers,
- 120+ projects **delivered** on top of Sylius,
- 25+ **countries** of BitBag’s customers,
- 4+ **years** in the Sylius ecosystem.

**Our services:**
- Business audit/Consulting in the field of **strategy** development,
- Data/shop **migration**,
- Headless **eCommerce**,
- Personalized **software** development,
- **Project** maintenance and long term support,
- Technical **support**.

**Key clients:** Mollie, Guave, P24, Folkstar, i-LUNCH, Elvi Project, WestCoast Gifts.

---

If you need some help with Sylius development, don't be hesitated to contact us directly. You can fill the form on [this site](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) or send us an e-mail at [email protected]!

---

[![](https://bitbag.io/wp-content/uploads/2021/08/sylius-badges-transparent-wide.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms)

## Community

----

For online communication, we invite you to chat with us & other users on [Sylius Slack](https://sylius-devs.slack.com/).

# Demo Sylius Shop

---

We created a demo app with some useful use-cases of plugins!
Visit [sylius-demo.bitbag.io](https://sylius-demo.bitbag.io/) to take a look at it. The admin can be accessed under
[sylius-demo.bitbag.io/admin/login](https://sylius-demo.bitbag.io/admin/login) link and `bitbag: bitbag` credentials.
Plugins that we have used in the demo:

| BitBag's Plugin | GitHub | Sylius' Store|
| ------ | ------ | ------|
| ACL Plugin | *Private. Available after the purchasing.*| https://plugins.sylius.com/plugin/access-control-layer-plugin/|
| Braintree Plugin | https://github.com/BitBagCommerce/SyliusBraintreePlugin |https://plugins.sylius.com/plugin/braintree-plugin/|
| CMS Plugin | https://github.com/BitBagCommerce/SyliusCmsPlugin | https://plugins.sylius.com/plugin/cmsplugin/|
| Elasticsearch Plugin | https://github.com/BitBagCommerce/SyliusElasticsearchPlugin | https://plugins.sylius.com/plugin/2004/|
| Mailchimp Plugin | https://github.com/BitBagCommerce/SyliusMailChimpPlugin | https://plugins.sylius.com/plugin/mailchimp/ |
| Multisafepay Plugin | https://github.com/BitBagCommerce/SyliusMultiSafepayPlugin |
| Wishlist Plugin | https://github.com/BitBagCommerce/SyliusWishlistPlugin | https://plugins.sylius.com/plugin/wishlist-plugin/|
| **Sylius' Plugin** | **GitHub** | **Sylius' Store** |
| Admin Order Creation Plugin | https://github.com/Sylius/AdminOrderCreationPlugin | https://plugins.sylius.com/plugin/admin-order-creation-plugin/ |
| Invoicing Plugin | https://github.com/Sylius/InvoicingPlugin | https://plugins.sylius.com/plugin/invoicing-plugin/ |
| Refund Plugin | https://github.com/Sylius/RefundPlugin | https://plugins.sylius.com/plugin/refund-plugin/ |

**If you need an overview of Sylius' capabilities, schedule a consultation with our expert.**

[![](https://bitbag.io/wp-content/uploads/2020/10/button_free_consulatation-1.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms)

## Additional resources for developers

---
To learn more about our contribution workflow and more, we encourage you to use the following resources:
* [Sylius Documentation](https://docs.sylius.com/en/latest/)
* [Sylius Contribution Guide](https://docs.sylius.com/en/latest/contributing/)
* [Sylius Online Course](https://sylius.com/online-course/)


## License

---

This plugin's source code is completely free and released under the terms of the MIT license.

[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen.)

## Contact

---
If you want to contact us, the best way is to fill the form on [our website](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms) or send us an e-mail to [email protected] with your question(s). We guarantee that we answer as soon as we can!

[![](https://bitbag.io/wp-content/uploads/2021/08/badges-bitbag.png)](https://bitbag.io/contact-us/?utm_source=github&utm_medium=referral&utm_campaign=plugins_cms)
25 changes: 1 addition & 24 deletions behat.yml.dist
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
imports:
- vendor/sylius/sylius/src/Sylius/Behat/Resources/config/suites.yml
- tests/Behat/Resources/suites.yml

default:
formatters:
pretty:
verbose: true
paths: false
snippets: false

extensions:
DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~

Expand All @@ -28,24 +23,6 @@ default:
chrome:
api_url: http://127.0.0.1:9222
validate_certificate: false
chrome:
selenium2:
browser: chrome
capabilities:
browserName: chrome
browser: chrome
version: ""
marionette: null # https://github.com/Behat/MinkExtension/pull/311
chrome:
switches:
- "start-fullscreen"
- "start-maximized"
- "no-sandbox"
extra_capabilities:
unexpectedAlertBehaviour: accept
firefox:
selenium2:
browser: firefox
show_auto: false

FriendsOfBehat\SymfonyExtension:
Expand Down
Loading

0 comments on commit 903e5af

Please sign in to comment.