|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Contao Open Source CMS |
| 4 | + * |
| 5 | + * @author Christian Schiffler <c.schiffler@cyberspectrum.de> |
| 6 | + * @copyright CyberSpectrum 2014 |
| 7 | + * @package MultiColumnWizard |
| 8 | + * @license LGPL-3+ |
| 9 | + * @filesource |
| 10 | + */ |
| 11 | + |
| 12 | +namespace MenAtWork\MultiColumnWizard\Event; |
| 13 | + |
| 14 | +use ContaoCommunityAlliance\DcGeneral\Data\ModelInterface; |
| 15 | +use ContaoCommunityAlliance\DcGeneral\EnvironmentInterface; |
| 16 | +use Symfony\Component\EventDispatcher\Event; |
| 17 | + |
| 18 | +/** |
| 19 | + * This event is fired when a MultiColumnWizard wants to retrieve the options for a sub widget in dc-general context. |
| 20 | + */ |
| 21 | +class GetOptionsEvent extends Event |
| 22 | +{ |
| 23 | + const NAME = 'men-at-work.multi-column-wizard.get-options'; |
| 24 | + |
| 25 | + /** |
| 26 | + * The name of the multi column wizard. |
| 27 | + * |
| 28 | + * @var string |
| 29 | + */ |
| 30 | + protected $propertyName; |
| 31 | + |
| 32 | + /** |
| 33 | + * The name of the sub widget. |
| 34 | + * |
| 35 | + * @var string |
| 36 | + */ |
| 37 | + protected $subPropertyName; |
| 38 | + |
| 39 | + /** |
| 40 | + * The environment in use. |
| 41 | + * |
| 42 | + * @var EnvironmentInterface |
| 43 | + */ |
| 44 | + protected $environment; |
| 45 | + |
| 46 | + /** |
| 47 | + * The current model. |
| 48 | + * |
| 49 | + * @var ModelInterface |
| 50 | + */ |
| 51 | + protected $model; |
| 52 | + |
| 53 | + /** |
| 54 | + * The multi column wizard. |
| 55 | + * |
| 56 | + * @var \MultiColumnWizard |
| 57 | + */ |
| 58 | + protected $widget; |
| 59 | + |
| 60 | + /** |
| 61 | + * The options array. |
| 62 | + * |
| 63 | + * @var array |
| 64 | + */ |
| 65 | + protected $options; |
| 66 | + |
| 67 | + /** |
| 68 | + * Create a new instance. |
| 69 | + * |
| 70 | + * @param string $propertyName The name of the multi column wizard widget. |
| 71 | + * |
| 72 | + * @param string $subPropertyName The name of the sub widget. |
| 73 | + * |
| 74 | + * @param EnvironmentInterface $environment The environment instance. |
| 75 | + * |
| 76 | + * @param ModelInterface $model The current model. |
| 77 | + * |
| 78 | + * @param \MultiColumnWizard $widget The multi column wizard instance. |
| 79 | + * |
| 80 | + * @param array $options The current options (defaults to empty array). |
| 81 | + */ |
| 82 | + public function __construct( |
| 83 | + $propertyName, |
| 84 | + $subPropertyName, |
| 85 | + EnvironmentInterface $environment, |
| 86 | + ModelInterface $model, |
| 87 | + \MultiColumnWizard $widget, |
| 88 | + $options = array() |
| 89 | + ) { |
| 90 | + $this->propertyName = $propertyName; |
| 91 | + $this->subPropertyName = $subPropertyName; |
| 92 | + $this->environment = $environment; |
| 93 | + $this->model = $model; |
| 94 | + $this->widget = $widget; |
| 95 | + $this->options = $options; |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Retrieve the name of the multi column wizard property. |
| 100 | + * |
| 101 | + * @return string |
| 102 | + */ |
| 103 | + public function getPropertyName() |
| 104 | + { |
| 105 | + return $this->propertyName; |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Retrieve the name of the property within the multi column wizard. |
| 110 | + * |
| 111 | + * @return string |
| 112 | + */ |
| 113 | + public function getSubPropertyName() |
| 114 | + { |
| 115 | + return $this->subPropertyName; |
| 116 | + } |
| 117 | + |
| 118 | + /** |
| 119 | + * Retrieve the dc-general environment. |
| 120 | + * |
| 121 | + * @return EnvironmentInterface |
| 122 | + */ |
| 123 | + public function getEnvironment() |
| 124 | + { |
| 125 | + return $this->environment; |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Retrieve the model in dc-general scope. |
| 130 | + * |
| 131 | + * @return ModelInterface |
| 132 | + */ |
| 133 | + public function getModel() |
| 134 | + { |
| 135 | + return $this->model; |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * Retrieve the multi column wizard instance emitting the event. |
| 140 | + * |
| 141 | + * @return \MultiColumnWizard |
| 142 | + */ |
| 143 | + public function getWidget() |
| 144 | + { |
| 145 | + return $this->widget; |
| 146 | + } |
| 147 | + |
| 148 | + /** |
| 149 | + * Retrieve the options. |
| 150 | + * |
| 151 | + * @return array |
| 152 | + */ |
| 153 | + public function getOptions() |
| 154 | + { |
| 155 | + return $this->options; |
| 156 | + } |
| 157 | + |
| 158 | + /** |
| 159 | + * Set the options. |
| 160 | + * |
| 161 | + * @param array $options The options. |
| 162 | + * |
| 163 | + * @return GetOptionsEvent |
| 164 | + */ |
| 165 | + public function setOptions($options) |
| 166 | + { |
| 167 | + $this->options = $options; |
| 168 | + |
| 169 | + return $this; |
| 170 | + } |
| 171 | +} |
0 commit comments