first commit
This commit is contained in:
commit
e81864e683
2984 files changed
+267797
No files matched your search
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
namespace In2code\Femanager\Utility;
|
||||
|
||||
use Exception;
|
||||
use In2code\Femanager\Domain\Repository\UserGroupRepository;
|
||||
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
|
||||
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationExtensionNotConfiguredException;
|
||||
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
|
||||
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
||||
|
||||
/**
|
||||
* Class AbstractUtility
|
||||
*/
|
||||
abstract class AbstractUtility
|
||||
{
|
||||
/**
|
||||
* Get table configuration array for a defined table
|
||||
*
|
||||
* @param string $table
|
||||
* @return array
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
protected static function getTcaFromTable($table = 'fe_users'): array
|
||||
{
|
||||
$tca = [];
|
||||
if (!empty($GLOBALS['TCA'][$table])) {
|
||||
$tca = $GLOBALS['TCA'][$table];
|
||||
}
|
||||
return $tca;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ConnectionPool
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public static function getConnectionPool(): ConnectionPool
|
||||
{
|
||||
return GeneralUtility::makeInstance(ConnectionPool::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
protected static function getFilesArray(): array
|
||||
{
|
||||
return (array)$_FILES;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserGroupRepository
|
||||
*/
|
||||
protected static function getUserGroupRepository(): UserGroupRepository
|
||||
{
|
||||
return GeneralUtility::makeInstance(UserGroupRepository::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TypoScriptFrontendController|null
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
protected static function getTypoScriptFrontendController()
|
||||
{
|
||||
return $GLOBALS['TSFE'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get TYPO3 encryption key
|
||||
*
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
protected static function getEncryptionKey(): string
|
||||
{
|
||||
if (empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) {
|
||||
throw new \UnexpectedValueException('No encryption key found in this TYPO3 installation', 1516373945265);
|
||||
}
|
||||
return $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get extension configuration from LocalConfiguration.php
|
||||
*
|
||||
* @return array
|
||||
* @throws ExtensionConfigurationExtensionNotConfiguredException
|
||||
* @throws ExtensionConfigurationPathDoesNotExistException
|
||||
*/
|
||||
protected static function getExtensionConfiguration(): array
|
||||
{
|
||||
return (array)GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('femanager');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ContentObjectRenderer
|
||||
* @throws Exception
|
||||
*/
|
||||
protected static function getContentObject(): ContentObjectRenderer
|
||||
{
|
||||
return GeneralUtility::makeInstance(ContentObjectRenderer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ConfigurationManagerInterface
|
||||
* @codeCoverageIgnore
|
||||
* @throws Exception
|
||||
*/
|
||||
protected static function getConfigurationManager(): ConfigurationManagerInterface
|
||||
{
|
||||
return GeneralUtility::makeInstance(ConfigurationManagerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BackendUserAuthentication
|
||||
* @SuppressWarnings(PHPMD.Superglobals)
|
||||
*/
|
||||
protected static function getBackendUserAuthentication()
|
||||
{
|
||||
return $GLOBALS['BE_USER'];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user