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\Event\AbstractModelAwareEvent;
16: use DcGeneral\EnvironmentInterface;
17: use DcGeneral\Data\ModelInterface;
18: use DcGeneral\DataDefinition\Definition\View\ListingConfigInterface;
19:
20: /**
21: * Class GetGroupHeaderEvent.
22: *
23: * Render the group header in the listing view.
24: *
25: * @package DcGeneral\Contao\View\Contao2BackendView\Event
26: */
27: class GetGroupHeaderEvent
28: extends AbstractModelAwareEvent
29: {
30: const NAME = 'dc-general.view.contao2backend.get-group-header';
31:
32: /**
33: * The current property to be rendered for the group header.
34: *
35: * @var string
36: */
37: protected $groupField;
38:
39: /**
40: * The grouping mode in use as defined in the listing config.
41: *
42: * @var string
43: *
44: * @see ListingConfigInterface
45: */
46: protected $groupingMode;
47:
48: /**
49: * The value to be rendered.
50: *
51: * @var string
52: */
53: protected $value;
54:
55: /**
56: * Create a new group header event.
57: *
58: * @param EnvironmentInterface $environment The environment.
59: *
60: * @param ModelInterface $model The model being used as group header.
61: *
62: * @param string $propertyName The name of the property being rendered into the group header.
63: *
64: * @param mixed $propertyValue The value of the property being rendered into the group header.
65: *
66: * @param string $groupingMode The grouping mode currently active.
67: */
68: public function __construct(
69: EnvironmentInterface $environment,
70: ModelInterface $model,
71: $propertyName,
72: $propertyValue,
73: $groupingMode
74: )
75: {
76: parent::__construct($environment, $model);
77:
78: $this->groupField = $propertyName;
79: $this->value = $propertyValue;
80: $this->groupingMode = $groupingMode;
81: }
82:
83: /**
84: * Retrieve the property name to be rendered.
85: *
86: * @return string
87: */
88: public function getGroupField()
89: {
90: return $this->groupField;
91: }
92:
93: /**
94: * Get the grouping mode in use as defined in the listing config.
95: *
96: * @return string
97: *
98: * @see ListingConfigInterface
99: */
100: public function getGroupingMode()
101: {
102: return $this->groupingMode;
103: }
104:
105: /**
106: * Set the value to use in the group header.
107: *
108: * @param string $value The value.
109: *
110: * @return GetGroupHeaderEvent
111: */
112: public function setValue($value)
113: {
114: $this->value = $value;
115:
116: return $this;
117: }
118:
119: /**
120: * Retrieve the value to use in the group header.
121: *
122: * @return string
123: */
124: public function getValue()
125: {
126: return $this->value;
127: }
128: }
129: