PHP code example of teamneusta / pimcore-areabrick-config-bundle

1. Go to this page and download the library: Download teamneusta/pimcore-areabrick-config-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

teamneusta / pimcore-areabrick-config-bundle example snippets


   Neusta\Pimcore\AreabrickConfigBundle\NeustaPimcoreAreabrickConfigBundle::class => ['all' => true],
   



namespace App\Document\Areabrick;

use Neusta\Pimcore\AreabrickConfigBundle\DialogBoxBuilder;
use Neusta\Pimcore\AreabrickConfigBundle\HasDialogBox;
use Pimcore\Extension\Document\Areabrick\AbstractTemplateAreabrick;
use Pimcore\Extension\Document\Areabrick\EditableDialogBoxInterface;
use Pimcore\Model\Document\Editable;
use Pimcore\Model\Document\Editable\Area\Info;

class MyAreabrick extends AbstractTemplateAreabrick implements EditableDialogBoxInterface
{   
    /** @template-use HasDialogBox<DialogBoxBuilder> */
    use HasDialogBox;

    private function buildDialogBox(DialogBoxBuilder $dialogBox, Editable $area, ?Info $info): void
    {
        $dialogBox
            ->addNamedTab('settings', 'Settings',
                $dialogBox->createInput('my-input')
                    ->setLabel('Text Input')
                    ->setPlaceholder('Please enter text...')
            )
            ->addNamedTab('options', 'Options',
                $dialogBox->createCheckbox('my-checkbox')
                    ->setLabel('Activate')
                    ->setDefaultChecked()
            );
    }
}

$dialogBox
    ->width(800)
    ->height(600)
    ->reloadOnClose(true);

$dialogBox->addContent(
    $dialogBox->createInput('field-1'),
    $dialogBox->createInput('field-2')
);

$dialogBox->addTab('tab_name', 'Tab Title', 
    $dialogBox->createInput('field-1'),
    $dialogBox->createInput('field-2')
);

$dialogBox->createInput('name')
    ->setLabel('Label')
    ->setPlaceholder('Placeholder')
    ->setDefaultValue('Default value')
    ->setWidth(300);

$dialogBox->createCheckbox('name')
    ->setLabel('Label')
    ->setDefaultChecked(); // or setDefaultUnchecked()

$dialogBox->createSelect('name', [
    'value1' => 'Label 1',
    'value2' => 'Label 2',
])
    ->setLabel('Selection')
    ->setDefaultValue('value2');

$dialogBox->createRelation('my-relation')
    ->setLabel('Relation')
    ->allowObjectsOfClass('MyPimcoreClass')
    ->allowAssetsOfType('image')
    ->allowDocumentsOfType('page');

$dialogBox->createLink('my-link')
    ->setLabel('Link')
    ->allowTypes('document', 'asset', 'object')
    ->disallowFields('anchor', 'rel');

$dialogBox->createNumeric('count', 1, 10)
    ->setLabel('Count')
    ->setDefaultValue(5);

$dialogBox->createDate('date')
    ->setLabel('Date')
    ->setFormat('d.m.Y');

$dialogBox->createInput('name')
    ->addConfig('any-editable-config-key', 'value');



namespace App\Areabrick;

use Neusta\Pimcore\AreabrickConfigBundle\DialogBoxBuilder;
use Neusta\Pimcore\AreabrickConfigBundle\DialogBoxConfigurator;
use Pimcore\Model\Document\Editable;
use Pimcore\Model\Document\Editable\Area\Info;

final class MyAreabrickDialogBoxConfigurator implements DialogBoxConfigurator
{
    public function configureDialogBox(DialogBoxBuilder $dialogBox, Editable $area, ?Info $info): void
    {
        $dialogBox->height(500);

        $dialogBox->getTab('Settings')
            ->getEditable('my-input')
                ->setDefaultValue('Custom Context Value');

        $dialogBox->reloadOnClose(false);
    }
}