enm/json-api-object-resource-mapper-bundle

Symfony integration for object resource mappers from enm/json-api-common

1.0.3 2020-01-02 12:38 UTC

This package is auto-updated.

Last update: 2024-10-29 04:47:49 UTC


README

Symfony integration for object and resource mappers from enm/json-api-server-common

  1. Installation
  2. Usage

Installation

composer require enm/json-api-server-common

in your AppKernel:

<?php
// config/bundles.php
return [
    // ...
    Enm\Bundle\JsonApi\Mapper\EnmJsonApiMapperBundle::class => ['all'=>true],
    // ...
];

Usage

Your object mappers must be defined as services and tagged with json_api.object_mapper to be detected by this bundle.

Your resource mappers must be defined as services and tagged with json_api.resource_mapper to be detected by this bundle.

services:
    app.mappers.example:
        class: App\Mappers\ExampleMapper # this mapper will implement object and resource mapper interface...
        tags:
            - { name: 'json_api.object_mapper' }
            - { name: 'json_api.resource_mapper' }

The registry service, which you will need for dependency injection, is Enm\JsonApi\Mapper\ObjectResourceMapper.