Skip to content
Snippets Groups Projects
Commit 7d89596b authored by Matthias Adrowski's avatar Matthias Adrowski
Browse files

[TASK] TYPO3 Constant migration + guards

parent f2b4ebf8
No related branches found
No related tags found
1 merge request!38Feature upgrade to typo3 11
...@@ -27,6 +27,7 @@ namespace SGalinski\SgNews\Domain\Repository; ...@@ -27,6 +27,7 @@ namespace SGalinski\SgNews\Domain\Repository;
***************************************************************/ ***************************************************************/
use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings; use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
use TYPO3\CMS\Extbase\Persistence\QueryInterface; use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\Repository;
...@@ -43,44 +44,15 @@ abstract class AbstractRepository extends Repository { ...@@ -43,44 +44,15 @@ abstract class AbstractRepository extends Repository {
* @return void * @return void
*/ */
public function initializeObject() { public function initializeObject() {
/** @var $querySettings Typo3QuerySettings */ /** @var Typo3QuerySettings $querySettings */
$querySettings = $this->objectManager->get(Typo3QuerySettings::class); $querySettings = $this->objectManager->get(Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(FALSE); $querySettings->setRespectStoragePage(FALSE);
if (TYPO3_MODE === 'BE') { if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()) {
$querySettings->setIgnoreEnableFields(TRUE); $querySettings->setIgnoreEnableFields(TRUE);
} }
$this->setDefaultQuerySettings($querySettings); $this->setDefaultQuerySettings($querySettings);
} }
/**
* Method creates a statement string of the enableFields for the given database table.
*
* @param string $table
* @param string $alias
* @param bool $ignoreEnableFields
* @return string
* @throws \InvalidArgumentException
*/
protected function getEnableFieldsStatement($table, $alias = '', $ignoreEnableFields = FALSE): string {
if (TYPO3_MODE === 'FE' && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController) {
/** @var PageRepository $pageRepository */
$pageRepository = $GLOBALS['TSFE']->sys_page;
$statement = $pageRepository->enableFields($table);
} else {
$statement = BackendUtility::deleteClause($table);
if (!$ignoreEnableFields) {
$statement .= BackendUtility::BEenableFields($table);
}
}
if ($alias !== '') {
$statement = str_replace($table, $alias, $statement);
}
return $statement;
}
/** /**
* This count returns the right amount of results, in contrast to $query->execute()->count(), which does not respect * This count returns the right amount of results, in contrast to $query->execute()->count(), which does not respect
* the language- nor the workspace overlay. * the language- nor the workspace overlay.
......
<?php <?php
defined('TYPO3') or die();
/** /**
* *
* Copyright notice * Copyright notice
......
<?php <?php
defined('TYPO3') or die();
/** /**
* *
* Copyright notice * Copyright notice
......
<?php <?php
defined('TYPO3') or die();
/** /**
* *
* Copyright notice * Copyright notice
......
<?php <?php
defined('TYPO3') or die();
/** /**
* *
* Copyright notice * Copyright notice
......
<?php <?php
defined('TYPO3') or die();
/** /**
* *
* Copyright notice * Copyright notice
...@@ -30,23 +31,21 @@ call_user_func( ...@@ -30,23 +31,21 @@ call_user_func(
'tx_sgnews_domain_model_author' 'tx_sgnews_domain_model_author'
); );
if (TYPO3_MODE === 'BE') { $navigationComponentId = 'TYPO3/CMS/Backend/PageTree/PageTreeElement';
$navigationComponentId = 'TYPO3/CMS/Backend/PageTree/PageTreeElement'; \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( 'SgNews',
'SgNews', 'web',
'web', 'News',
'News', '',
'', [
[ \SGalinski\SgNews\Controller\BackendController::class => 'index',
\SGalinski\SgNews\Controller\BackendController::class => 'index', ],
], [
[ 'access' => 'user,group',
'access' => 'user,group', 'icon' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg',
'icon' => 'EXT:sg_news/Resources/Public/Icons/module-sgnews.svg', 'labels' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang.xlf',
'labels' => 'LLL:EXT:sg_news/Resources/Private/Language/locallang.xlf', 'navigationComponentId' => $navigationComponentId
'navigationComponentId' => $navigationComponentId ]
] );
);
}
} }
); );
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment