coshi/variator-bundle

Symfony CoshiVariatorBundle

Installs: 35

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 9

Forks: 0

Open Issues: 0

Type:symfony-bundle

v0.0.2 2016-08-24 08:29 UTC

This package is not auto-updated.

Last update: 2024-04-19 18:00:24 UTC


README

Allows to specify callbacks with services:

    'text' => [
        'type' => 'int',
        'min' => 0,
        'max' => ['@some_service', 'someMethod']

Brings new variation type: "iteratorResult" to operate over the Doctrine IterableResult

Usage:

    $builder = $container->get('coshi.variator_bundle.builder');
    
    $config = [
        'id' => [
            'type' => 'iteratorResult',
            'callback' => ['@some_repository', 'getSomeIds'],
        ],
    ];
    $variations = $builder->build($config);
    
    foreach ($variations as $values) {
        foreach($values as $value) {
            print($value); // displays ids one by one            
        }
    }

You can strip values to several chunks. Variator will then fetch the data using LIMIT and OFFSET SQL statements:

    $builder = $container->get('coshi.variator_bundle.builder');
    
    $config = [
        'id' => [
            'type' => 'iteratorResult',
            'callback' => ['@some_repository', 'getSomeIds'],
            'chunked' => true,
            'chunk_size' => 100
        ],
    ];
    $variations = $builder->build($config);
    
    foreach ($variations as $values) {
        foreach($values as $value) {
            print($value); // displays ids one by one, same as in previous            
        }
    }