Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (23 sloc) 611 Bytes

Processors

Processors can be used to extend the functionality of a formatter.

Using Anonymous Functions

$processor = function (array $data, $object) {
    $data['class'] = get_class($object);

    return $data;
};

$formatter->addProcessor($processor);

Using AbstractProcessor

use Graze\Formatter\Processor\AbstractProcessor;

final class ClassNameProcessor extends AbstractProcessor
{
    protected function process(array $data, $object)
    {
        $data['class'] = get_class($object);

        return $data;
    }
}

$formatter->addProcessor(new ClassNameProcessor());