1: <?php
2:
3: /**
4: * PHP version 5
5: *
6: * @package generalDriver
7: * @author Christian Schiffler <c.schiffler@cyberspectrum.de>
8: * @author Stefan Heimes <stefan_heimes@hotmail.com>
9: * @author Tristan Lins <tristan.lins@bit3.de>
10: * @copyright The MetaModels team.
11: * @license LGPL.
12: * @filesource
13: */
14:
15: namespace DcGeneral\DataDefinition\Builder;
16:
17: use DcGeneral\Factory\Event\BuildDataDefinitionEvent;
18:
19: /**
20: * Class AbstractEventDrivenDataDefinitionBuilder.
21: *
22: * Abstract base class for an data definition builder.
23: *
24: * To use it, implement the method build() and register the class to the event dispatcher.
25: *
26: * @package DcGeneral\DataDefinition\Builder
27: */
28: abstract class AbstractEventDrivenDataDefinitionBuilder implements DataDefinitionBuilderInterface
29: {
30: /**
31: * Priority of the listener.
32: * Just here for sanity, must be overwritten by implementation.
33: */
34: const PRIORITY = null;
35:
36: /**
37: * Creates an instance of itself and processes the event.
38: *
39: * The attached data definition {@link DcGeneral\DataDefinition\ContainerInterface}
40: * will be populated with the information from the builder's data source.
41: *
42: * @param BuildDataDefinitionEvent $event The event to process.
43: *
44: * @return void
45: */
46: public static function process(BuildDataDefinitionEvent $event)
47: {
48: $builder = new static();
49: /** @var DataDefinitionBuilderInterface $builder */
50: $builder->build($event->getContainer(), $event);
51: }
52: }
53: