Skip to content

Commit

Permalink
Documentation of ArrayExclusionStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgf authored and Miguel Gonzalez committed Dec 20, 2016
1 parent ad51b00 commit c1a596b
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ This is installable via [Composer](https://getcomposer.org/) as [sp/fixture-dump

### Basic Usage ###

Examples:

```php
$manager = ...; // entity or document manager
$registry = new \Sp\FixtureDumper\Converter\Handler\HandlerRegistry();
Expand All @@ -30,16 +28,31 @@ $ymlGenerator = new \Sp\FixtureDumper\Generator\Alice\YamlFixtureGenerator();
// for creating array files which can be loaded with the alice fixtures library
$arrayGenerator = new \Sp\FixtureDumper\Generator\Alice\ArrayFixtureGenerator();

$generatorMap = new \PhpCollection\Map(array('class' => $generator, 'yml' => $ymlGenerator, 'array' => $arrayGenerator);
$dumper = new \Sp\FixtureDumper\ORMDumper($manager, $registry, $generatorMap));
$generatorMap = new \PhpCollection\Map(array('class' => $generator, 'yml' => $ymlGenerator, 'array' => $arrayGenerator));
$dumper = new \Sp\FixtureDumper\ORMDumper($manager, $registry, $generatorMap);
// or
$dumper = new \Sp\FixtureDumper\MongoDBDumper($manager, $registry, $generatorMap));
$dumper = new \Sp\FixtureDumper\MongoDBDumper($manager, $registry, $generatorMap);
// $dumper->setDumpMultipleFiles(false);

// the second argument specifies the generator type you want to use
$dumper->dump('/your/workspace/src/Acme/DemoBundle/DataFixtures/ORM', 'array');
```

### Exclusion Strategy ###

You can implement the interface `ExclusionStrategyInterface` to define the strategy to select the entities to dump.

```php
// ...
$dumper = new \Sp\FixtureDumper\ORMDumper($manager, $registry, $generatorMap);

// The entity Post and Comment won't be dumped
$exclusion = new ArrayExclusionStrategy(['Post', 'Acme\DemoBundle\Entity\Comment']);
$dumper->setExclusionStrategy($exclusion);

$dumper->dump(...);
```

#### Options

`AbstractDumper#dump` accepts a third `$options` argument that is an array
Expand Down

0 comments on commit c1a596b

Please sign in to comment.