Code Duplication    Length = 26-26 lines in 2 locations

Admin/CoreAdmin.php 2 locations

@@ 351-376 (lines=26) @@
348
     * @param type $tabName    the name of the tab to be renamed
349
     * @param type $newTabName the new name for the tab
350
     */
351
    public function renameFormTab($tabName, $newTabName, $keepOrder = true)
352
    {
353
        $tabs = $this->getFormTabs();
354
355
        if (!$tabs) {
356
            return;
357
        }
358
359
        if (!isset($tabs[$tabName])) {
360
            throw new \Exception(sprintf('Tab %s does not exist.', $tabName));
361
        }
362
        if (isset($tabs[$newTabName])) {
363
            return;
364
        }
365
366
        if ($keepOrder) {
367
            $keys = array_keys($tabs);
368
            $keys[array_search($tabName, $keys)] = $newTabName;
369
            $tabs = array_combine($keys, $tabs);
370
        } else {
371
            $tabs[$newTabName] = $tabs[$tabName];
372
            unset($tabs[$tabName]);
373
        }
374
375
        $this->setFormTabs($tabs);
376
    }
377
378
    /**
379
     * Rename a show tab after show fields have been configured.
@@ 386-411 (lines=26) @@
383
     * @param type $tabName    the name of the tab to be renamed
384
     * @param type $newTabName the new name for the tab
385
     */
386
    public function renameShowTab($tabName, $newTabName, $keepOrder = true)
387
    {
388
        $tabs = $this->getShowTabs();
389
390
        if (!$tabs) {
391
            return;
392
        }
393
394
        if (!isset($tabs[$tabName])) {
395
            throw new \Exception(sprintf('Tab %s does not exist.', $tabName));
396
        }
397
        if (isset($tabs[$newTabName])) {
398
            return;
399
        }
400
401
        if ($keepOrder) {
402
            $keys = array_keys($tabs);
403
            $keys[array_search($tabName, $keys)] = $newTabName;
404
            $tabs = array_combine($keys, $tabs);
405
        } else {
406
            $tabs[$newTabName] = $tabs[$tabName];
407
            unset($tabs[$tabName]);
408
        }
409
410
        $this->setShowTabs($tabs);
411
    }
412
413
    /**
414
     * Rename a form group.