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\DataDefinition\Palette\Builder\Event;
14:
15: use DcGeneral\DataDefinition\Palette\Condition\Palette\PropertyValueCondition as PalettePropertyValueCondition;
16: use DcGeneral\DataDefinition\Palette\Condition\Property\PropertyValueCondition;
17: use DcGeneral\DataDefinition\Palette\Builder\PaletteBuilder;
18: use DcGeneral\Exception\DcGeneralInvalidArgumentException;
19:
20: /**
21: * This event gets emitted when a property value condition gets created.
22: *
23: * @package DcGeneral\DataDefinition\Palette\Builder\Event
24: */
25: class CreatePropertyValueConditionEvent extends BuilderEvent
26: {
27: const NAME = 'dc-general.data-definition.palette.builder.create-property-value-condition';
28:
29: /**
30: * The property value condition.
31: *
32: * @var PalettePropertyValueCondition|PropertyValueCondition
33: */
34: protected $propertyValueCondition;
35:
36: /**
37: * Create a new instance.
38: *
39: * @param PalettePropertyValueCondition|PropertyValueCondition $propertyValueCondition The condition.
40: *
41: * @param PaletteBuilder $paletteBuilder The palette builder in use.
42: */
43: public function __construct($propertyValueCondition, PaletteBuilder $paletteBuilder)
44: {
45: $this->setPropertyValueCondition($propertyValueCondition);
46: parent::__construct($paletteBuilder);
47: }
48:
49: /**
50: * Set the property value condition.
51: *
52: * @param PalettePropertyValueCondition|PropertyValueCondition $propertyValueCondition The property value condition.
53: *
54: * @return CreatePropertyValueConditionEvent
55: *
56: * @throws DcGeneralInvalidArgumentException When an invalid condition has been passed.
57: */
58: public function setPropertyValueCondition($propertyValueCondition)
59: {
60: if (!($propertyValueCondition instanceof PalettePropertyValueCondition)
61: && (!$propertyValueCondition instanceof PropertyValueCondition))
62: {
63: throw new DcGeneralInvalidArgumentException();
64: }
65:
66: $this->propertyValueCondition = $propertyValueCondition;
67: return $this;
68: }
69:
70: /**
71: * Retrieve the property value condition.
72: *
73: * @return PalettePropertyValueCondition|PropertyValueCondition
74: */
75: public function getPropertyValueCondition()
76: {
77: return $this->propertyValueCondition;
78: }
79: }
80: