Skip to content

Commit 45c5f0a

Browse files
committed
Remove duplicated code
1 parent 996125f commit 45c5f0a

File tree

1 file changed

+12
-30
lines changed

1 file changed

+12
-30
lines changed

types/Page.php

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,6 @@ class Page extends AbstractMultiBaseType
2626
]
2727
];
2828

29-
/**
30-
* Return the current configuration.
31-
* Overwrites parent method to migrate deprecated options.
32-
*
33-
* @return array
34-
*/
35-
public function getConfig()
36-
{
37-
// migrate autocomplete options 'namespace' and 'postfix' to 'filter'
38-
if (empty($this->config['autocomplete']['filter'])) {
39-
if (!empty($this->config['autocomplete']['namespace'])) {
40-
$this->config['autocomplete']['filter'] = $this->config['autocomplete']['namespace'];
41-
unset($this->config['autocomplete']['namespace']);
42-
}
43-
if (!empty($this->config['autocomplete']['postfix'])) {
44-
$this->config['autocomplete']['filter'] .= '.+?' . $this->config['autocomplete']['postfix'] . '$';
45-
unset($this->config['autocomplete']['namespace']);
46-
}
47-
}
48-
return $this->config;
49-
}
50-
5129
/**
5230
* Output the stored data
5331
*
@@ -105,14 +83,6 @@ public function handleAjax()
10583

10684
$filter = $this->config['autocomplete']['filter'];
10785

108-
// try to use deprecated options namespace and postfix as filter
109-
$namespace = $this->config['autocomplete']['namespace'] ?? '';
110-
$postfix = $this->config['autocomplete']['postfix'] ?? '';
111-
if (!$filter) {
112-
$filter = $namespace ? $namespace . ':' : '';
113-
$filter .= $postfix ? '.+?' . $postfix . '$' : '';
114-
}
115-
11686
// this basically duplicates what we do in ajax_qsearch() but with a filter
11787
$result = [];
11888
$counter = 0;
@@ -283,5 +253,17 @@ protected function mergeConfig($current, &$config)
283253
$config[$key] = $value;
284254
}
285255
}
256+
257+
// migrate autocomplete options 'namespace' and 'postfix' to 'filter'
258+
if (empty($config['autocomplete']['filter'])) {
259+
if (!empty($config['autocomplete']['namespace'])) {
260+
$config['autocomplete']['filter'] = $config['autocomplete']['namespace'];
261+
unset($config['autocomplete']['namespace']);
262+
}
263+
if (!empty($config['autocomplete']['postfix'])) {
264+
$config['autocomplete']['filter'] .= '.+?' . $config['autocomplete']['postfix'] . '$';
265+
unset($config['autocomplete']['postfix']);
266+
}
267+
}
286268
}
287269
}

0 commit comments

Comments
 (0)