Skip to content

Commit

Permalink
#1251 Fix references to Modules class
Browse files Browse the repository at this point in the history
  • Loading branch information
j3nsch committed Oct 30, 2024
1 parent 22a7616 commit d0f3556
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 11 deletions.
3 changes: 2 additions & 1 deletion library/Application/Translate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Application\Modules;
use Opus\Common\Config;
use Opus\Common\LoggingTrait;
use Opus\Translate\Dao;
Expand Down Expand Up @@ -116,7 +117,7 @@ public static function setInstance($instance)
public function loadModules($reload = false)
{
if (! $this->loaded || $reload) {
$modules = Application_Modules::getInstance()->getModules();
$modules = Modules::getInstance()->getModules();

foreach ($modules as $name => $module) {
$moduleDir = APPLICATION_PATH . '/modules/' . $name;
Expand Down
5 changes: 3 additions & 2 deletions library/Application/Translate/TranslationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Application\Modules;
use Opus\Common\Translate\TranslateException;
use Opus\Common\Translate\UnknownTranslationKeyException;
use Opus\Translate\Dao;
Expand Down Expand Up @@ -136,7 +137,7 @@ public function getModules()
$allowedModules = $this->getAllowedModules();

if ($allowedModules === null) {
$modulesManager = Application_Modules::getInstance();
$modulesManager = Modules::getInstance();
$allowedModules = array_keys($modulesManager->getModules());
}

Expand All @@ -161,7 +162,7 @@ public function getAllowedModules()
if (! empty($value)) {
$modules = array_map('trim', explode(',', $value));

$allModules = Application_Modules::getInstance()->getModules();
$allModules = Modules::getInstance()->getModules();

$allowedModules = [];

Expand Down
3 changes: 2 additions & 1 deletion library/Application/Update/ImportCustomTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Application\Modules;
use Opus\Common\Console\ConsoleColors;
use Opus\Translate\Dao;

Expand All @@ -42,7 +43,7 @@ class Application_Update_ImportCustomTranslations extends Application_Update_Plu
*/
public function run()
{
$modules = array_keys(Application_Modules::getInstance()->getModules());
$modules = array_keys(Modules::getInstance()->getModules());

$manager = new Application_Translate_TranslationManager();
$manager->setFolderNames('language_custom');
Expand Down
3 changes: 2 additions & 1 deletion modules/admin/controllers/AccessController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Application\Modules;
use Opus\Common\UserRole;
use Opus\Common\UserRoleInterface;

Expand Down Expand Up @@ -108,7 +109,7 @@ public function listmoduleAction()
$this->view->roleName = $role->getName();
$this->view->modules = $roleModules;

$modules = array_keys(Application_Modules::getInstance()->getModules());
$modules = array_keys(Modules::getInstance()->getModules());
unset($modules['default']);

$this->view->allModules = $modules;
Expand Down
3 changes: 2 additions & 1 deletion modules/admin/controllers/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Application\Modules;
use Opus\Common\Account;
use Opus\Common\AccountInterface;
use Opus\Common\UserRole;
Expand Down Expand Up @@ -110,7 +111,7 @@ public function showAction()
$this->_helper->redirector('index');
}

$modules = array_keys(Application_Modules::getInstance()->getModules());
$modules = array_keys(Modules::getInstance()->getModules());
unset($modules['default']);

$this->view->allModules = $modules;
Expand Down
4 changes: 3 additions & 1 deletion modules/admin/controllers/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Application\Modules;

/**
* Controller for module management.
*/
Expand All @@ -41,7 +43,7 @@ class Admin_ModuleController extends Application_Controller_Action
*/
public function indexAction()
{
$modules = Application_Modules::getInstance()->getModules();
$modules = Modules::getInstance()->getModules();

$this->view->modules = $modules;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Application\Modules;

class Application_Form_Element_TranslationModulesTest extends ControllerTestCase
{
/** @var string */
Expand Down Expand Up @@ -60,7 +62,7 @@ public function testInitAllModules()

$options = $element->getMultiOptions();

$modules = array_keys(Application_Modules::getInstance()->getModules());
$modules = array_keys(Modules::getInstance()->getModules());

$this->assertCount(count($modules) + 1, $options);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/library/Application/ModulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testGetInstance()
$modules = Modules::getInstance();

$this->assertNotNull($modules);
$this->assertInstanceOf('Application_Modules', $modules);
$this->assertInstanceOf(Modules::class, $modules);

$this->assertSame($modules, Modules::getInstance());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Application\Modules;
use Opus\Common\Translate\TranslateException;
use Opus\Common\Translate\UnknownTranslationKeyException;
use Opus\Translate\Dao;
Expand Down Expand Up @@ -760,7 +761,7 @@ public function testGetModulesNoRestrictions()

$modules = $manager->getModules();

$modulesManager = Application_Modules::getInstance();
$modulesManager = Modules::getInstance();

$this->assertEquals(array_keys($modulesManager->getModules()), $modules);
}
Expand Down
4 changes: 3 additions & 1 deletion tests/library/Application/View/Helper/AdminCssClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

use Opus\Application\Modules;

class Application_View_Helper_AdminCssClassTest extends ControllerTestCase
{
/** @var string */
Expand All @@ -39,7 +41,7 @@ class Application_View_Helper_AdminCssClassTest extends ControllerTestCase
*/
public function modulesProvider()
{
$modules = Application_Modules::getInstance()->getModules();
$modules = Modules::getInstance()->getModules();

$data = [];

Expand Down

0 comments on commit d0f3556

Please sign in to comment.