Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time

Store Provider for (Multi-) Select Editables

This Bundle allows you to generate dynamic data for your dropdown elements. If you're in pimcore context, a typical store looks like this:

toolbox:
    areas:
        video:
            config_elements:
                a_classical_store:
                    type: multiselect
                    title: 'Test 2'
                    config:
                        store:
                            my_value: 'My Value'
                            foo: 'Bar'

Configure Dynamic Store Provider

But you're also able to provide your data from a symfony service:

toolbox:
    areas:
        video:
            config_elements:
                my_dynamic_store_provider:
                    type: select
                    title: 'Test'
                    config:
                        store_provider: 'my_awesome_store_provider'

Register Custom Store Provider

Now we need to register our new service:

# app/config.yml
services:
    App\Toolbox\MyStoreProvider:
        tags:
            - { name: toolbox.editable.store_provider, identifier: 'my_awesome_store_provider' }

Create Store Provider

<?php

namespace App\Toolbox;

use ToolboxBundle\Provider\StoreProviderInterface;

class MyStoreProvider implements StoreProviderInterface
{
    public function getValues(): array
    {
        return [
            'my_value' => 'My Value',
            'foo'      => 'Bar'
        ];
    }
}