jojo1981/data-resolver-handlers

Handlers for the data resolver

4.0.0 2023-02-10 12:43 UTC

This package is auto-updated.

Last update: 2024-11-10 16:19:04 UTC


README

Build Status Coverage Status Latest Stable Version Total Downloads License

Author: Joost Nijhuis <jnijhuis81@gmail.com>

This library is an extension for the jojo1981/data-resolver package and contains custom handlers which add support to work with some 3th party libraries.

This library has support for:

  • instances of Doctrine\Common\Collections\Collection from the package doctrine/collections.
  • instances of Jojo1981\TypedCollection\Collection from the package jojo1981/typed-collection.

Installation

Library

git clone https://github.com/jojo1981/data-resolver-handlers.git

Composer

Install PHP Composer

composer require jojo1981/data-resolver-handlers

Usage

<?php

require 'vendor/autoload.php';

// get factory and register handlers
$factory = (new \Jojo1981\DataResolver\Factory())
    ->useDefaultSequenceHandlers()
    ->registerSequenceHandler(new \Jojo1981\DataResolverHandlers\DoctrineCollectionSequenceHandler())
    ->registerSequenceHandler(new \Jojo1981\DataResolverHandlers\TypedCollectionSequenceHandler())
    ->setMergeHandler(
        new \Jojo1981\DataResolverHandlers\DoctrineCollectionMergeHandlerDecorator(
            new \Jojo1981\DataResolverHandlers\TypedCollectionMergeHandlerDecorator(
                new \Jojo1981\DataResolver\Handler\MergeHandler\DefaultMergeHandler()    
            )
        )
    );

// get resolver builder factory
$resolverBuilderFactory = $factory->getResolverBuilderFactory();

// and you're ready to go