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\Contao\View\Contao2BackendView\Event;
14:
15: use DcGeneral\Data\ModelInterface;
16: use DcGeneral\DataDefinition\Definition\Properties\PropertyInterface;
17: use DcGeneral\EnvironmentInterface;
18: use DcGeneral\Event\AbstractModelAwareEvent;
19:
20: /**
21: * Class ManipulateWidgetEvent.
22: *
23: * This event gets emitted when a widget shall get manipulated.
24: * This happens directly after all the initialization has been done.
25: *
26: * If you want to create the widget entirely by yourself refer to the BuildWidgetEvent event.
27: *
28: * @package DcGeneral\Contao\View\Contao2BackendView\Event
29: *
30: * @see BuildWidgetEvent
31: */
32: class ManipulateWidgetEvent
33: extends AbstractModelAwareEvent
34: {
35: const NAME = 'dc-general.view.contao2backend.manipulate-widget';
36:
37: /**
38: * The widget instance to manipulate.
39: *
40: * @var \Widget
41: */
42: protected $widget;
43:
44: /**
45: * The property information for which the widget has been created.
46: *
47: * @var PropertyInterface
48: */
49: protected $property;
50:
51: /**
52: * Create a new event.
53: *
54: * @param EnvironmentInterface $environment The environment in use.
55: *
56: * @param ModelInterface $model The model for which the widget is created.
57: *
58: * @param PropertyInterface $property The property information for which the widget is created.
59: *
60: * @param \Widget $widget The widget instance to manipulate.
61: */
62: public function __construct(
63: EnvironmentInterface $environment,
64: ModelInterface $model,
65: PropertyInterface $property,
66: \Widget $widget
67: )
68: {
69: parent::__construct($environment, $model);
70:
71: $this->property = $property;
72: $this->widget = $widget;
73: }
74:
75: /**
76: * Retrieve the widget instance.
77: *
78: * @return \Widget
79: */
80: public function getWidget()
81: {
82: return $this->widget;
83: }
84:
85: /**
86: * Retrieve the property information for which the widget is created for.
87: *
88: * @return PropertyInterface
89: */
90: public function getProperty()
91: {
92: return $this->property;
93: }
94: }
95: