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\GetBreadcrumbEvent;
16: use DcGeneral\DC_General;
17:
18: /**
19: * Class ContainerGetBreadcrumbCallbackListener.
20: *
21: * Callback handler for breadcrumbs in backend.
22: *
23: * @package DcGeneral\Contao\Callback
24: */
25: class ContainerGetBreadcrumbCallbackListener 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 GetBreadcrumbEvent $event The event being emitted.
51: *
52: * @return array
53: */
54: public function getArgs($event)
55: {
56: return array(
57: $this->dcGeneral
58: );
59: }
60:
61: /**
62: * Update the information in the event with the list of breadcrumb elements returned by the callback.
63: *
64: * @param GetBreadcrumbEvent $event The event being emitted.
65: *
66: * @param array $value The breadcrumb elements returned by the callback.
67: *
68: * @return void
69: */
70: public function update($event, $value)
71: {
72: if (is_null($value))
73: {
74: return;
75: }
76:
77: $event->setElements($value);
78: }
79: }
80: