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\Callback;
14:
15: use DcGeneral\Contao\Compatibility\DcCompat;
16: use DcGeneral\Contao\View\Contao2BackendView\Event\BuildWidgetEvent;
17: use DcGeneral\DC_General;
18:
19: /**
20: * Class PropertyInputFieldCallbackListener.
21: *
22: * Handle input_field_callbacks.
23: *
24: * @package DcGeneral\Contao\Callback
25: */
26: class PropertyInputFieldCallbackListener extends AbstractReturningCallbackListener
27: {
28: /**
29: * The DC_General instance.
30: *
31: * @var DC_General
32: */
33: protected $dcGeneral;
34:
35: /**
36: * Create a new instance of the listener.
37: *
38: * @param array|callable $callback The callback to call when invoked.
39: *
40: * @param DC_General $dcGeneral The DC_General instance to use in the callback.
41: */
42: public function __construct($callback, DC_General $dcGeneral)
43: {
44: parent::__construct($callback);
45: $this->dcGeneral = $dcGeneral;
46: }
47:
48: /**
49: * Retrieve the arguments for the callback.
50: *
51: * @param BuildWidgetEvent $event The event being emitted.
52: *
53: * @return array
54: */
55: public function getArgs($event)
56: {
57: return array($event->getProperty(), new DcCompat($event->getEnvironment(), $event->getModel(), $event->getProperty()));
58: }
59:
60: /**
61: * Update the widget in the event.
62: *
63: * @param BuildWidgetEvent $event The event being emitted.
64: *
65: * @param \Widget $value The widget that has been constructed.
66: *
67: * @return void
68: */
69: public function update($event, $value)
70: {
71: $event->setWidget($value);
72: }
73: }
74: