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\View\Contao2BackendView\Event\GetParentHeaderEvent;
16: use DcGeneral\DC_General;
17:
18: /**
19: * Class ContainerHeaderCallbackListener.
20: *
21: * Handler for the header row in parent list mode.
22: *
23: * @package DcGeneral\Contao\Callback
24: */
25: class ContainerHeaderCallbackListener extends AbstractReturningCallbackListener
26: {
27: /**
28: * The DC_General instance.
29: *
30: * @var \DcGeneral\DC_General
31: */
32: protected $dcGeneral;
33:
34: /**
35: * Create a new instance of the listener.
36: *
37: * @param array|callable $callback The callback to call when invoked.
38: *
39: * @param DC_General $dcGeneral The DC_General instance to use in the callback.
40: */
41: public function __construct($callback, DC_General $dcGeneral)
42: {
43: parent::__construct($callback);
44: $this->dcGeneral = $dcGeneral;
45: }
46:
47: /**
48: * Retrieve the arguments for the callback.
49: *
50: * @param GetParentHeaderEvent $event The event being emitted.
51: *
52: * @return array
53: */
54: public function getArgs($event)
55: {
56: return array($event->getAdditional(), $this->dcGeneral);
57: }
58:
59: /**
60: * Update the event with the information returned by the callback.
61: *
62: * @param GetParentHeaderEvent $event The event being emitted.
63: *
64: * @param array $value The additional information.
65: *
66: * @return void
67: */
68: public function update($event, $value)
69: {
70: if (is_null($value))
71: {
72: return;
73: }
74:
75: $event->setAdditional($value);
76: $event->stopPropagation();
77: }
78: }
79: