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\DataDefinition\Definition\View\ModelFormatterConfigInterface;
16: use DcGeneral\Event\AbstractModelAwareEvent;
17:
18: /**
19: * Class ModelToLabelEvent.
20: *
21: * This event gets emitted when a model shall be translated to an html representation.
22: *
23: * @package DcGeneral\Contao\View\Contao2BackendView\Event
24: */
25: class ModelToLabelEvent
26: extends AbstractModelAwareEvent
27: {
28: const NAME = 'dc-general.view.contao2backend.model-to-label';
29:
30: /**
31: * The label for the model.
32: *
33: * This is a format string to use in vsprintf().
34: *
35: * @var string
36: */
37: protected $label;
38:
39: /**
40: * The label information instance.
41: *
42: * @var ModelFormatterConfigInterface
43: */
44: protected $listLabel;
45:
46: /**
47: * The arguments to use when building the label from the format string.
48: *
49: * @var array
50: */
51: protected $args;
52:
53: /**
54: * Set the arguments to use when generating the final string representation using the format string.
55: *
56: * @param array $args The arguments.
57: *
58: * @return ModelToLabelEvent
59: */
60: public function setArgs($args)
61: {
62: $this->args = $args;
63:
64: return $this;
65: }
66:
67: /**
68: * Retrieve the arguments to use when generating the final string representation using the format string.
69: *
70: * @return array
71: */
72: public function getArgs()
73: {
74: return $this->args;
75: }
76:
77: /**
78: * Set the label for the model.
79: *
80: * This is a format string to use in vsprintf().
81: *
82: * @param string $label The label string.
83: *
84: * @return ModelToLabelEvent
85: */
86: public function setLabel($label)
87: {
88: $this->label = $label;
89:
90: return $this;
91: }
92:
93: /**
94: * Get the label for the model.
95: *
96: * This is a format string to use in vsprintf().
97: *
98: * @return string
99: */
100: public function getLabel()
101: {
102: return $this->label;
103: }
104:
105: /**
106: * Set the label information instance.
107: *
108: * @param ModelFormatterConfigInterface $listLabel The label information instance.
109: *
110: * @return ModelToLabelEvent
111: */
112: public function setFormatter($listLabel)
113: {
114: $this->listLabel = $listLabel;
115:
116: return $this;
117: }
118:
119: /**
120: * Retrieve the label information instance.
121: *
122: * @return ModelFormatterConfigInterface
123: */
124: public function getFormatter()
125: {
126: return $this->listLabel;
127: }
128: }
129: