Someone used new backend "Record Mappers"?

The Record Mappers feature is very interesting. Unfortunately there is no documentation yet.

Hello Simone,

no docs / not used it so far as well.

I haven’t tried it myself, but maybe an idea:

If you use Cursor and ask an AI to write a documentation with examples, based on the code … I’d be curious about the output and whether it’s already acceptable / useful.

Just a few generic pointers. There is a scheme that is used in several places, leveraging Symphony, and its used for Record Mappers.

It’s a way of building a “registry” of classes to call, just based on the fact that they implement an interface.

You can start tracking it from config/core_services.yaml, some services get tagged, and the registry class is called with a list of those tagged services.

If you have a class that implements one of the RecordMapper interfaces, the Symphony cache:clear should pick it up, and you can check it like this:

symfony console debug:container ViewDefinitionMapperInterface

Some of the Docs and videos use similar mechanisms.

Once it is loaded into the registry, normally some place in the code will iterate and call all defined mappers when it is appropriate.

Now Work, this is a sample code. Thankyou


namespace App\Extension\GcrmB2bExt\modules\Meetings\Service\Record\Mappers;

use App\Data\Entity\Record;
use App\Data\Service\Record\EntityRecordMappers\EntityRecordFieldMapperInterface;
use App\FieldDefinitions\Entity\FieldDefinition;
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;

#[Autoconfigure(lazy: true)]
class MeetingSalesStageMapper implements EntityRecordFieldMapperInterface
{
    public const FIELD_NAME = 'opp_status';

    public function getField(): string
    {
        return self::FIELD_NAME;
    }

    public function replaceDefaultTypeMapper(): bool
    {
        return false;
    }

    public function getModule(): string
    {
        return 'default';
    }

    public function getKey(): string
    {
        return 'meeting-opp_status-change-to-enum';
    }

    public function getModes(): array
    {
        return ['list'];
    }

    public function getOrder(): int
    {
        return 10;
    }

    public function toInternal(Record $record, FieldDefinition $fieldDefinitions): void
    {

    }

    public function toExternal(Record $record, FieldDefinition $fieldDefinitions): void
    {
        $a = $record->getAttributes();
        $v = $fieldDefinitions->getVardef();
    }


}


2 Likes