Skip to content

Commit

Permalink
[TASK] #15 | Move InternalContentObjects module into debug namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
KamiYang committed Oct 23, 2018
1 parent 35d56ac commit 1dd7bcb
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/UserSessionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Class FrontendUserSessionRepository
* Class UserSessionRepository
*/
class UserSessionRepository
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);

namespace Psychomieze\AdminpanelExtended\Modules\Info;
namespace Psychomieze\AdminpanelExtended\Modules\Debug;

/*
* This file is part of the TYPO3 Adminpanel Initiative.
Expand Down Expand Up @@ -37,7 +37,9 @@ public function getIdentifier(): string
*/
public function getLabel(): string
{
return 'Internal Content Objects';
return $this->getLanguageService()->sL(
'LLL:EXT:adminpanel_extended/Resources/Private/Language/locallang_debug.xlf:submodule.internalContentObjects.label'
);
}

/**
Expand Down
12 changes: 8 additions & 4 deletions Classes/Modules/Info/UserInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ class UserInformation extends AbstractSubModule implements DataProviderInterface
*/
private $backendUserSessionRepository;

public function __construct(UserSessionRepository $frontendUserSessionRepository = null, UserSessionRepository $backendUserSessionRepository = null)
{
$this->frontendUserSessionRepository = $frontendUserSessionRepository ?? GeneralUtility::makeInstance(UserSessionRepository::class, UserSessionRepository::CONTEXT_FE);
$this->backendUserSessionRepository = $backendUserSessionRepository ?? GeneralUtility::makeInstance(UserSessionRepository::class, UserSessionRepository::CONTEXT_BE);
public function __construct(
UserSessionRepository $frontendUserSessionRepository = null,
UserSessionRepository $backendUserSessionRepository = null
) {
$this->frontendUserSessionRepository = $frontendUserSessionRepository ?? GeneralUtility::makeInstance(UserSessionRepository::class,
UserSessionRepository::CONTEXT_FE);
$this->backendUserSessionRepository = $backendUserSessionRepository ?? GeneralUtility::makeInstance(UserSessionRepository::class,
UserSessionRepository::CONTEXT_BE);
}

/**
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_debug.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<trans-unit id="submodule.hooks.label">
<source>Hooks</source>
</trans-unit>
<trans-unit id="submodule.internalContentObjects.label">
<source>Internal Content Objects</source>
</trans-unit>
</body>
</file>
</xliff>
55 changes: 55 additions & 0 deletions Tests/Unit/Modules/Debug/InternalContentObjectsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);

namespace Psychomieze\AdminpanelExtended\Tests\Unit\Modules\Debug;

/*
* This file is part of the TYPO3 Adminpanel Initiative.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

use Psychomieze\AdminpanelExtended\Modules\Debug\InternalContentObjects;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

/**
* Class InternalContentObjectsTest
*/
class InternalContentObjectsTest extends UnitTestCase
{
/**
* @var \Psychomieze\AdminpanelExtended\Modules\Debug\InternalContentObjects
*/
protected $subject;

protected function setUp(): void
{
parent::setUp();
$this->subject = new InternalContentObjects();
}

/**
* @test
*/
public function getIdentifierReturnsUniqueSubModuleIdentifier(): void
{
static::assertSame('internal-content-objects', $this->subject->getIdentifier());
}

/**
* @test
*/
public function getLabelShouldCallLanguageServiceForLocalizedLanguageLabel(): void
{
$languageServiceProphecy = $this->prophesize(LanguageService::class);
$labelIdentifier = 'LLL:EXT:adminpanel_extended/Resources/Private/Language/locallang_debug.xlf:submodule.internalContentObjects.label';
$languageServiceProphecy->sL($labelIdentifier)->willReturn('some LLL');
$GLOBALS['LANG'] = $languageServiceProphecy->reveal();

$this->subject->getLabel();

$languageServiceProphecy->sL($labelIdentifier)->shouldHaveBeenCalledTimes(1);
}
}
1 change: 0 additions & 1 deletion Tests/Unit/Modules/Info/UserInformationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use TYPO3\CMS\Adminpanel\ModuleApi\DataProviderInterface;
use TYPO3\CMS\Adminpanel\ModuleApi\ModuleData;
use TYPO3\CMS\Adminpanel\ModuleApi\ResourceProviderInterface;
use TYPO3\CMS\Beuser\Domain\Repository\BackendUserSessionRepository;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
Expand Down
32 changes: 14 additions & 18 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,30 @@ function () {
[
'hooks' => [
'module' => \Psychomieze\AdminpanelExtended\Modules\HooksAndSignals\Hooks::class,
'after' => [
'log',
],
'after' => ['log']
],
'signals' => [
'module' => \Psychomieze\AdminpanelExtended\Modules\HooksAndSignals\Signals::class,
'after' => ['hooks'],
'after' => ['hooks']
],
'internal-content-objects' => [
'module' => Psychomieze\AdminpanelExtended\Modules\Debug\InternalContentObjects::class,
'after' => ['signals']
]
]
);
}

if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']['info'])) {
$infoSubModules = [
'internal-content-objects' => [
'module' => Psychomieze\AdminpanelExtended\Modules\Info\InternalContentObjects::class
]
];

if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('beuser')) {
$infoSubModules['userinformation'] = [
'module' => Psychomieze\AdminpanelExtended\Modules\Info\UserInformation::class
];
}

if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']['info']) &&
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('beuser')) {
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']['info']['submodules'] = array_replace_recursive(
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']['info']['submodules'],
$infoSubModules
[
'userinformation' => [
'module' => Psychomieze\AdminpanelExtended\Modules\Info\UserInformation::class,
'after' => ['request']
]
]
);
}
}
Expand Down

0 comments on commit 1dd7bcb

Please sign in to comment.