Skip to content

Commit

Permalink
Readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
marekrzytki committed Jun 25, 2024
1 parent fea11d0 commit 7298496
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,7 @@ imports:
- { resource: "@BitBagSyliusAgreementPlugin/Resources/config/config.yaml" }
```

5. Update database schema:
##### Check for queries to execute
```
bin/console doctrine:schema:update --dump-sql
```
##### Execute database update
```
bin/console doctrine:schema:update --force
```
## Usage
***
1.Find a form/forms where you want to add agreements and set it in your config.yaml file, for example:
```yaml
bit_bag_sylius_agreement:
contexts:
registration_form:
- Sylius\Bundle\CoreBundle\Form\Type\Customer\CustomerRegistrationType
checkout_form:
- Sylius\Bundle\CoreBundle\Form\Type\Checkout\AddressType
```

2.Find an entity which is used in your form and add trait to that class:
##### For customer entity
5. Extend Customer entity:
```php
<?php
Expand All @@ -125,7 +100,6 @@ class Customer extends BaseCustomer implements CustomerInterface
}
```

##### Customer interface
```php
<?php
Expand All @@ -138,6 +112,35 @@ interface CustomerInterface extends BaseCustomerInterface
}
```

6. Update database schema:
##### Check for queries to execute
```
bin/console doctrine:schema:update --dump-sql
```
##### Execute database update
```
bin/console doctrine:schema:update --force
```
## Usage
***
1.Find a form/forms where you want to add agreements and set it in your config.yaml file, for example:
```yaml
bit_bag_sylius_agreement:
contexts:
registration_form:
- Sylius\Bundle\CoreBundle\Form\Type\Customer\CustomerRegistrationType
checkout_form:
- Sylius\Bundle\CoreBundle\Form\Type\Checkout\AddressType
```

2.Find an entity which is used in your form and add trait to that class:
```php
use AgreementsRequiredTrait;
```

3.In the admin panel, create a new agreement and select context to it according to the configuration in the config.yaml file.

4.[Overwrite](https://symfony.com/doc/3.4/templating/overriding.html) templates used by yours extended form by adding:
Expand All @@ -147,7 +150,6 @@ interface CustomerInterface extends BaseCustomerInterface
{{ form_row(agreement.approved) }}
{% endfor %}
````
##### For example registration form use: 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
Expand Down

0 comments on commit 7298496

Please sign in to comment.