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