Skip to main content
Version: Next

Create a Custom Backend Adapter

To create a custom backend adapter, you need to follow three steps:

  1. Create a new PHP class for your custom backend adapter;
  2. Register it as a service tagged pimcore.backend_power_tools.alternative_element_trees.data_object.adapter;
  3. Add the adapter class to the mapping.

Create the PHP Class​

You must define getAdapterValues function that returns the adapter's value while extending \Pimcore\Bundle\BackendPowerToolsBundle\Adapter\AlternativeElementTree\DataObject\AbstractObjectAdapter:

<?php

namespace App\Adapter\AlternativeElementTree;

class CustomAdapter extends \Pimcore\Bundle\BackendPowerToolsBundle\Adapter\AlternativeElementTree\DataObject\AbstractObjectAdapter
{
// start implementing
protected function getAdapterValues(): array
{
...
}
}

Tag the Service​

Without the tag the adapter is not found and no value is shown:

services:
App\Adapter\AlternativeElementTree\CustomAdapter:
autowire: true
tags:
- { name: 'pimcore.backend_power_tools.alternative_element_trees.data_object.adapter' }

Add the Adapter Type to the Mapping​

The last step is to add the adapter type to the mapping. This can be done in the config.yaml of your bundle.

pimcore_backend_power_tools:
pimcore_alternative_object_trees:
adapters:
input: #= the datatype of the corresponding class field
frontend: SimpleValueAdapter
backend: App\Adapter\AlternativeElementTree\CustomAdapter