|
30 | 30 | */ |
31 | 31 | class TestdataButtons |
32 | 32 | { |
33 | | - //functions for import buttons |
| 33 | + /** Button status constants */ |
| 34 | + private const SHOW_BUTTONS = 1; |
| 35 | + private const HIDE_BUTTONS = 0; |
| 36 | + |
34 | 37 | /** |
| 38 | + * Load the test button configuration |
| 39 | + * |
35 | 40 | * @param \Xmf\Module\Admin $adminObject |
| 41 | + * |
36 | 42 | * @return void |
37 | 43 | */ |
38 | | - public static function loadButtonConfig(\Xmf\Module\Admin $adminObject) |
| 44 | + public static function loadButtonConfig($adminObject): void |
39 | 45 | { |
40 | | - $moduleDirName = \basename(\dirname(__DIR__, 2)); |
41 | | - $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
42 | | - $yamlFile = \dirname(__DIR__, 2) . '/config/admin.yml'; |
43 | | - $config[] = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps |
44 | | - $displaySampleButton = $config[0]['displaySampleButton']; |
| 46 | + $moduleDirName = \basename(\dirname(__DIR__, 2)); |
| 47 | + $moduleDirNameUpper = \mb_strtoupper($moduleDirName); |
45 | 48 | $helper = Helper::getInstance(); |
| 49 | + $yamlFile = $helper->path('/config/admin.yml'); |
| 50 | + $config = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps |
| 51 | + $displaySampleButton = $config['displaySampleButton']; |
46 | 52 |
|
47 | | - if (1 == $displaySampleButton) { |
| 53 | + if (self::SHOW_BUTTONS == $displaySampleButton) { |
48 | 54 | \xoops_loadLanguage('admin/modulesadmin', 'system'); |
49 | 55 | $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'LOAD_SAMPLEDATA'), $helper->url('testdata/index.php?op=load'), 'add'); |
50 | 56 | $adminObject->addItemButton(\constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), $helper->url('testdata/index.php?op=save'), 'add'); |
|
0 commit comments