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\View\Event;
14:
15: use DcGeneral\Data\ModelInterface;
16: use DcGeneral\DataDefinition\Definition\Properties\PropertyInterface;
17: use DcGeneral\EnvironmentInterface;
18: use DcGeneral\Event\AbstractModelAwareEvent;
19:
20: /**
21: * This event is emitted when a property value of a model shall be transformed into a readable string representation.
22: *
23: * @package DcGeneral\View\Event
24: */
25: class RenderReadablePropertyValueEvent
26: extends AbstractModelAwareEvent
27: {
28: const NAME = 'dc-general.view.contao2backend.render-readable-property-value';
29:
30: /**
31: * The property that shall be transformed.
32: *
33: * @var PropertyInterface
34: */
35: protected $property;
36:
37: /**
38: * The value that shall be transformed.
39: *
40: * @var mixed
41: */
42: protected $value;
43:
44: /**
45: * The transformed string representation.
46: *
47: * @var string|null
48: */
49: protected $rendered = null;
50:
51: /**
52: * Create a new instance.
53: *
54: * @param EnvironmentInterface $environment The environment in use.
55: *
56: * @param ModelInterface $model The model the value originates from.
57: *
58: * @param PropertyInterface $property The property to transform.
59: *
60: * @param mixed $value The value to transform.
61: */
62: public function __construct(
63: EnvironmentInterface $environment,
64: ModelInterface $model,
65: PropertyInterface $property,
66: $value
67: )
68: {
69: parent::__construct($environment, $model);
70: $this->property = $property;
71: $this->value = $value;
72: }
73:
74: /**
75: * Retrieve the property.
76: *
77: * @return PropertyInterface
78: */
79: public function getProperty()
80: {
81: return $this->property;
82: }
83:
84: /**
85: * Retrieve the value.
86: *
87: * @return mixed
88: */
89: public function getValue()
90: {
91: return $this->value;
92: }
93:
94: /**
95: * Set the rendered value.
96: *
97: * @param null|string $rendered The rendered string representation or null to clear the representation.
98: *
99: * @return RenderReadablePropertyValueEvent
100: */
101: public function setRendered($rendered)
102: {
103: $this->rendered = $rendered;
104: return $this;
105: }
106:
107: /**
108: * Retrieve the rendered string representation.
109: *
110: * @return null|string
111: */
112: public function getRendered()
113: {
114: return $this->rendered;
115: }
116: }
117: