Skip to content

Commit 413d3fa

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/dev'
2 parents 814ac20 + ae91b52 commit 413d3fa

4 files changed

Lines changed: 213 additions & 14 deletions

File tree

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848
"contao-community-alliance/composer-installer": "*"
4949
},
5050
"autoload":{
51-
"classmap":["system/"]
51+
"classmap":["system/"],
52+
"psr-4": {
53+
"MenAtWork\\MultiColumnWizard\\": "system/modules/multicolumnwizard/src/"
54+
}
5255
},
5356
"replace": {
5457
"contao-legacy/multicolumnwizard": "*"
@@ -60,7 +63,8 @@
6063
}
6164
},
6265
"branch-alias": {
63-
"dev-dev": "3.2.x-dev"
66+
"dev-master": "3.3.x-dev",
67+
"dev-dev": "3.4.x-dev"
6468
}
6569
}
6670
}

system/modules/multicolumnwizard/MultiColumnWizard.php

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,9 @@ protected function initializeWidget(&$arrField, $intRow, $strKey, $varValue)
740740
if (defined('YACE'))
741741
$strContaoPrefix = '';
742742

743+
//pass activeRecord to widget
744+
$arrField['activeRecord'] = $this->activeRecord;
745+
743746
// Toggle line wrap (textarea)
744747
if ($arrField['inputType'] == 'textarea' && $arrField['eval']['rte'] == '')
745748
{
@@ -905,20 +908,40 @@ public function handleDcGeneral($arrData, $strName)
905908
unset($arrData['options_callback']);
906909
}
907910

908-
$environment = $this->objDca->getEnvironment();
909911
/* @var \ContaoCommunityAlliance\DcGeneral\EnvironmentInterface $environment */
910-
$event = new \ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent($environment, $this->objDca->getModel());
911-
$event->setPropertyName($strName);
912-
$event->setOptions($arrData['options']);
913-
$environment->getEventPropagator()->propagate(
914-
$event::NAME,
915-
$event,
916-
array(
917-
$environment->getDataDefinition()->getName(),
918-
$this->strName,
919-
$strName
920-
)
912+
$environment = $this->objDca->getEnvironment();
913+
// FIXME: begin of legacy code to be removed.
914+
if (method_exists($environment, 'getEventPropagator'))
915+
{
916+
$event = new \ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\GetPropertyOptionsEvent($environment, $this->objDca->getModel());
917+
$event->setPropertyName($strName);
918+
$event->setOptions($arrData['options']);
919+
$environment->getEventPropagator()->propagate(
920+
$event::NAME,
921+
$event,
922+
array(
923+
$environment->getDataDefinition()->getName(),
924+
$this->strName,
925+
$strName
926+
)
927+
);
928+
929+
if ($event->getOptions() !== $arrData['options'])
930+
{
931+
$arrData['options'] = $event->getOptions();
932+
}
933+
}
934+
// FIXME: end of legacy code to be removed.
935+
936+
$event = new \MenAtWork\MultiColumnWizard\Event\GetOptionsEvent(
937+
$this->strName,
938+
$strName,
939+
$environment,
940+
$this->objDca->getModel(),
941+
$this,
942+
$arrData['options']
921943
);
944+
$environment->getEventDispatcher()->dispatch($event::NAME, $event);
922945

923946
if ($event->getOptions() !== $arrData['options'])
924947
{

system/modules/multicolumnwizard/config/autoload.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
(
1919
'MultiColumnWizardHelper' => 'system/modules/multicolumnwizard/MultiColumnWizardHelper.php',
2020
'MultiColumnWizard' => 'system/modules/multicolumnwizard/MultiColumnWizard.php',
21+
'MenAtWork\MultiColumnWizard\Event\GetOptionsEvent' => 'system/modules/multicolumnwizard/src/Event/GetOptionsEvent.php',
2122
));
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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

Comments
 (0)