|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
| 4 | +namespace Neusta\Pimcore\AreabrickConfigBundle; |
| 5 | + |
| 6 | +use Pimcore\Model\Document\Editable; |
| 7 | +use Pimcore\Model\Document\Editable\Area\Info; |
| 8 | + |
| 9 | +/** |
| 10 | + * Allows configuring a {@see DialogBoxBuilder} instance. |
| 11 | + * |
| 12 | + * This is useful if you want to customize the default configuration, |
| 13 | + * for example, if the areabrick is used within the area of another areabrick. |
| 14 | + * In this case, you may, for example, want to change the default values of an item |
| 15 | + * or the possible values of a select item. |
| 16 | + * |
| 17 | + * ``` |
| 18 | + * namespace App\Areabrick; |
| 19 | + * |
| 20 | + * use Neusta\Pimcore\AreabrickConfigBundle\DialogBoxBuilder; |
| 21 | + * use Neusta\Pimcore\AreabrickConfigBundle\DialogBoxConfigurator; |
| 22 | + * use Pimcore\Model\Document\Editable; |
| 23 | + * use Pimcore\Model\Document\Editable\Area\Info; |
| 24 | + * |
| 25 | + * final class MyAreabrickDialogBoxConfigurator implements DialogBoxConfigurator |
| 26 | + * { |
| 27 | + * public function configureDialogBox(DialogBoxBuilder $dialogBox, Editable $area, ?Info $info): void |
| 28 | + * { |
| 29 | + * $dialogBox->height(500); |
| 30 | + * |
| 31 | + * $dialogBox->getTab('General') |
| 32 | + * ->getEditableItem('my-select') |
| 33 | + * ->setStore([ |
| 34 | + * 'option1' => 'Option 1', |
| 35 | + * 'option2' => 'Option 2', |
| 36 | + * ]) |
| 37 | + * ->setDefaultValue('option2'); |
| 38 | + * |
| 39 | + * $dialogBox->reloadOnClose(false); |
| 40 | + * } |
| 41 | + * } |
| 42 | + * ``` |
| 43 | + * |
| 44 | + * After registering the configurator with its FQCN in the container, |
| 45 | + * the configurator can be used like this: |
| 46 | + * |
| 47 | + * ``` |
| 48 | + * {{ pimcore_area('myfield', { |
| 49 | + * type: 'my-areabrick', |
| 50 | + * params: { |
| 51 | + * 'my-areabrick': { |
| 52 | + * dialogBoxConfigurator: 'App\Areabrick\MyAreabrickDialogBoxConfigurator', |
| 53 | + * } |
| 54 | + * }, |
| 55 | + * }) }} |
| 56 | + * ``` |
| 57 | + */ |
| 58 | +interface DialogBoxConfigurator |
| 59 | +{ |
| 60 | + public function configureDialogBox(DialogBoxBuilder $dialogBox, Editable $area, ?Info $info): void; |
| 61 | +} |
0 commit comments