Skip to content

Commit

Permalink
bug #316 Don't remove driver options when extending a grid configurat…
Browse files Browse the repository at this point in the history
…ion (loic425)

This PR was merged into the 1.12 branch.

Discussion
----------

Based on #317 

```php
<?php

use App\Entity\Suplier;
use Sylius\Bundle\GridBundle\Builder\GridBuilder;
use Sylius\Bundle\GridBundle\Config\GridConfig;

return static function (GridConfig $grid) {
    $grid->addGrid(
        GridBuilder::create('sylius_admin_product_variant')
    );
};

```

When running this following command:
```bash
$ bin/console debug:config sylius_grid grids.sylius_admin_product_variant.driver
```

Before
```yaml
name: doctrine/orm
options: {  }
```

After
```yaml
name: doctrine/orm
options:
    class: App\Entity\Product\ProductVariant
    repository:
        method: createQueryBuilderByProductId
        arguments:
            - "expr:service('sylius.context.locale').getLocaleCode()"
            - $productId
```

Commits
-------

c7d75bd Don't remove driver options when extending a grid configuration
  • Loading branch information
GSadee authored Jan 5, 2024
2 parents c9a493e + c7d75bd commit 3982f7c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Bundle/Builder/GridBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,14 @@ public function toArray(): array
$output = [
'driver' => [
'name' => $this->driver,
'options' => $this->driverConfiguration,
],
'removals' => $this->removals,
];

if (count($this->driverConfiguration) > 0) {
$output['driver']['options'] = $this->driverConfiguration;
}

if (count($this->fields) > 0) {
$output['fields'] = array_map(function (FieldInterface $field) { return $field->toArray(); }, $this->fields);
}
Expand Down

0 comments on commit 3982f7c

Please sign in to comment.