Skip to content

Commit c1a596b

Browse files
miguelgfMiguel Gonzalez
authored and
Miguel Gonzalez
committed
Documentation of ArrayExclusionStrategy
1 parent ad51b00 commit c1a596b

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

README.md

+18-5
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ This is installable via [Composer](https://getcomposer.org/) as [sp/fixture-dump
1414

1515
### Basic Usage ###
1616

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

33-
$generatorMap = new \PhpCollection\Map(array('class' => $generator, 'yml' => $ymlGenerator, 'array' => $arrayGenerator);
34-
$dumper = new \Sp\FixtureDumper\ORMDumper($manager, $registry, $generatorMap));
31+
$generatorMap = new \PhpCollection\Map(array('class' => $generator, 'yml' => $ymlGenerator, 'array' => $arrayGenerator));
32+
$dumper = new \Sp\FixtureDumper\ORMDumper($manager, $registry, $generatorMap);
3533
// or
36-
$dumper = new \Sp\FixtureDumper\MongoDBDumper($manager, $registry, $generatorMap));
34+
$dumper = new \Sp\FixtureDumper\MongoDBDumper($manager, $registry, $generatorMap);
3735
// $dumper->setDumpMultipleFiles(false);
3836

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

41+
### Exclusion Strategy ###
42+
43+
You can implement the interface `ExclusionStrategyInterface` to define the strategy to select the entities to dump.
44+
45+
```php
46+
// ...
47+
$dumper = new \Sp\FixtureDumper\ORMDumper($manager, $registry, $generatorMap);
48+
49+
// The entity Post and Comment won't be dumped
50+
$exclusion = new ArrayExclusionStrategy(['Post', 'Acme\DemoBundle\Entity\Comment']);
51+
$dumper->setExclusionStrategy($exclusion);
52+
53+
$dumper->dump(...);
54+
```
55+
4356
#### Options
4457

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

0 commit comments

Comments
 (0)