[task] implement extension configuration interface

This commit is contained in:
Daniel Maier 2018-10-30 11:13:56 +01:00
parent 690e6a431d
commit fa74af3261
6 changed files with 84 additions and 11 deletions

17
Classes/Bootstrap.php Normal file
View file

@ -0,0 +1,17 @@
<?php
namespace Codappix\SearchCore;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
class Bootstrap
{
/**
* @return object|ObjectManager
*/
public static function getObjectManager()
{
return GeneralUtility::makeInstance(ObjectManager::class);
}
}

View file

@ -1,4 +1,5 @@
<?php <?php
namespace Codappix\SearchCore\Compatibility; namespace Codappix\SearchCore\Compatibility;
/* /*
@ -20,7 +21,13 @@ namespace Codappix\SearchCore\Compatibility;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService;
use Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface;
use Codappix\SearchCore\Utility\ExtensionConfiguration;
use Codappix\SearchCore\Utility\ExtensionConfiguration87;
use Codappix\SearchCore\Utility\ExtensionConfigurationInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Object\Container\Container; use TYPO3\CMS\Extbase\Object\Container\Container;
/** /**
@ -31,16 +38,39 @@ class ImplementationRegistrationService
{ {
public static function registerImplementations() public static function registerImplementations()
{ {
/** @var Container $container */
$container = GeneralUtility::makeInstance(Container::class); $container = GeneralUtility::makeInstance(Container::class);
$container->registerImplementation( if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 9000000) {
\Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class, $container->registerImplementation(
\Codappix\SearchCore\Compatibility\TypoScriptService::class ExtensionConfigurationInterface::class,
); ExtensionConfiguration::class
);
$container->registerImplementation( $container->registerImplementation(
\Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface::class, TypoScriptServiceInterface::class,
\Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService::class TypoScriptService::class
); );
$container->registerImplementation(
TcaTableServiceInterface::class,
TcaTableService::class
);
} else if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) {
$container->registerImplementation(
ExtensionConfigurationInterface::class,
ExtensionConfiguration87::class
);
$container->registerImplementation(
TypoScriptServiceInterface::class,
TypoScriptService::class
);
$container->registerImplementation(
TcaTableServiceInterface::class,
TcaTableService::class
);
}
} }
} }

View file

@ -0,0 +1,7 @@
<?php
namespace Codappix\SearchCore\Utility;
class ExtensionConfiguration extends \TYPO3\CMS\Core\Configuration\ExtensionConfiguration implements ExtensionConfigurationInterface
{
}

View file

@ -0,0 +1,11 @@
<?php
namespace Codappix\SearchCore\Utility;
class ExtensionConfiguration87 implements ExtensionConfigurationInterface
{
public function get($extensionKey)
{
return unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extensionKey]);
}
}

View file

@ -0,0 +1,8 @@
<?php
namespace Codappix\SearchCore\Utility;
interface ExtensionConfigurationInterface
{
public function get($extensionKey);
}

View file

@ -42,10 +42,10 @@ call_user_func(
\Codappix\SearchCore\Compatibility\ImplementationRegistrationService::registerImplementations(); \Codappix\SearchCore\Compatibility\ImplementationRegistrationService::registerImplementations();
// API does make use of object manager, therefore use GLOBALS // API does make use of object manager, therefore use GLOBALS
$extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class)->get($extensionKey); $extensionConfiguration = \Codappix\SearchCore\Bootstrap::getObjectManager()->get(\Codappix\SearchCore\Utility\ExtensionConfigurationInterface::class)->get($extensionKey);
if ($extensionConfiguration === false if ($extensionConfiguration === false
|| !isset($extensionConfiguration['disable']['elasticsearch']) || !isset($extensionConfiguration['disable']['elasticsearch'])
|| $extensionConfiguration['disable']['elasticsearch'] !== '1' || $extensionConfiguration['disable']['elasticsearch'] !== '1'