Skip to content

Commit

Permalink
Do not provide entity anymore, supply copy/paste info in README
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandoorn committed Jan 4, 2021
1 parent 0665598 commit c93f2a2
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 55 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Optional features:
1. Require plugin with composer:

```bash
composer require stefandoorn/sylius-street-number-plugin:^1.0@alpha
composer require stefandoorn/sylius-street-number-plugin:^1.0@beta
```

2. Add plugin class to your `AppKernel`.
Expand All @@ -31,14 +31,8 @@ Optional features:
```yaml
- { resource: "@SyliusStreetNumberPlugin/Resources/config/config.yml" }
```
4. (optional) Load address resource override (if you don't have this done in your project yet):
```yaml
- { resource: "@SyliusStreetNumberPlugin/Resources/config/resources.yml" }
```
5. Add doctrine mapping fields for table `sylius_address` (`config/doctrine/Address.orm.yml`):
4. Add doctrine mapping fields for table `sylius_address` (see `tests/Application/config/doctrine/Address.orm.yml`):
```yaml
...
Expand All @@ -55,11 +49,21 @@ Optional features:
type: string
nullable: true
```
In case you haven't already extended the Address class, Symfony will use the one from this bundle.
The `streetNumberAddition` field is always added, regardless whether you use it. It will be `null` in that cae.
5. Add to `_sylius.yaml`:
```yaml
...
sylius_addressing:
resources:
address:
classes:
model: App\Entity\Addressing\Address
```
6. Add to `SyliusAdminBundle/views/Common/Form/_address.html.twig`:
```twig
Expand Down
14 changes: 0 additions & 14 deletions src/Entity/Address.php

This file was deleted.

11 changes: 0 additions & 11 deletions src/Entity/Interfaces/AddressInterface.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/Resources/config/doctrine/Address.orm.yml

This file was deleted.

5 changes: 0 additions & 5 deletions src/Resources/config/resources.yml

This file was deleted.

14 changes: 14 additions & 0 deletions tests/Application/config/doctrine/Address.orm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
App\Entity\Addressing\Address:
type: entity
table: sylius_address
fields:
number:
column: street_number
type: string
nullable: false
options:
default: ''
addition:
column: street_number_addition
type: string
nullable: true
6 changes: 6 additions & 0 deletions tests/Application/config/packages/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ sylius_shop:
sylius_street_number:
features:
street_number_addition: true

sylius_addressing:
resources:
address:
classes:
model: App\Entity\Addressing\Address
7 changes: 7 additions & 0 deletions tests/Application/config/packages/doctrine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ doctrine:
charset: UTF8

url: '%env(resolve:DATABASE_URL)%'

orm:
mappings:
is_bundle: false
type: yml
dir: "%kernel.project_dir%/config/doctrine"
prefix: App\Entity
19 changes: 19 additions & 0 deletions tests/Application/src/Entity/Addressing/Address.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace App\Entity\Addressing;

use Doctrine\ORM\Mapping as ORM;
use StefanDoorn\SyliusStreetNumberPlugin\Entity\Interfaces\StreetNumberAwareInterface;
use StefanDoorn\SyliusStreetNumberPlugin\Entity\Traits\StreetNumberAddition;
use Sylius\Component\Core\Model\Address as BaseAddress;

/**
* @ORM\Entity
* @ORM\Table(name="sylius_address")
*/
class Address extends BaseAddress implements StreetNumberAwareInterface
{
use StreetNumberAddition;
}

0 comments on commit c93f2a2

Please sign in to comment.