Skip to content

Commit

Permalink
simplify code to replace ml field types (#607)
Browse files Browse the repository at this point in the history
simplify code to replace ml field types
  • Loading branch information
mjauvin authored Oct 2, 2020
1 parent f6e5450 commit e4985c0
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions classes/EventRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ public function registerModelTranslation($widget)
*/
protected function processFormMLFields($fields, $model)
{
$typesMap = [
'markdown' => 'mlmarkdowneditor',
'mediafinder' => 'mlmediafinder',
'repeater' => 'mlrepeater',
'richeditor' => 'mlricheditor',
'text' => 'mltext',
'textarea' => 'mltextarea',
];

$translatable = array_flip($model->getTranslatableAttributes());

/*
Expand All @@ -165,23 +174,8 @@ protected function processFormMLFields($fields, $model)

$type = array_get($config, 'type', 'text');

if ($type == 'text') {
$fields[$name]['type'] = 'mltext';
}
elseif ($type == 'textarea') {
$fields[$name]['type'] = 'mltextarea';
}
elseif ($type == 'richeditor') {
$fields[$name]['type'] = 'mlricheditor';
}
elseif ($type == 'markdown') {
$fields[$name]['type'] = 'mlmarkdowneditor';
}
elseif ($type == 'repeater') {
$fields[$name]['type'] = 'mlrepeater';
}
elseif ($type == 'mediafinder') {
$fields[$name]['type'] = 'mlmediafinder';
if (array_key_exists($type, $typesMap)) {
$fields[$name]['type'] = $typesMap[$type];
}
}

Expand Down

0 comments on commit e4985c0

Please sign in to comment.