mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 21:16:11 +01:00
[task] implement extension configuration interface
This commit is contained in:
parent
690e6a431d
commit
fa74af3261
6 changed files with 84 additions and 11 deletions
17
Classes/Bootstrap.php
Normal file
17
Classes/Bootstrap.php
Normal 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);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Codappix\SearchCore\Compatibility;
|
||||
|
||||
/*
|
||||
|
@ -20,7 +21,13 @@ namespace Codappix\SearchCore\Compatibility;
|
|||
* 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\VersionNumberUtility;
|
||||
use TYPO3\CMS\Extbase\Object\Container\Container;
|
||||
|
||||
/**
|
||||
|
@ -31,16 +38,39 @@ class ImplementationRegistrationService
|
|||
{
|
||||
public static function registerImplementations()
|
||||
{
|
||||
/** @var Container $container */
|
||||
$container = GeneralUtility::makeInstance(Container::class);
|
||||
|
||||
$container->registerImplementation(
|
||||
\Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class,
|
||||
\Codappix\SearchCore\Compatibility\TypoScriptService::class
|
||||
);
|
||||
if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 9000000) {
|
||||
$container->registerImplementation(
|
||||
ExtensionConfigurationInterface::class,
|
||||
ExtensionConfiguration::class
|
||||
);
|
||||
|
||||
$container->registerImplementation(
|
||||
\Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableServiceInterface::class,
|
||||
\Codappix\SearchCore\Domain\Index\TcaIndexer\TcaTableService::class
|
||||
);
|
||||
$container->registerImplementation(
|
||||
TypoScriptServiceInterface::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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
7
Classes/Utility/ExtensionConfiguration.php
Normal file
7
Classes/Utility/ExtensionConfiguration.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Codappix\SearchCore\Utility;
|
||||
|
||||
class ExtensionConfiguration extends \TYPO3\CMS\Core\Configuration\ExtensionConfiguration implements ExtensionConfigurationInterface
|
||||
{
|
||||
}
|
11
Classes/Utility/ExtensionConfiguration87.php
Normal file
11
Classes/Utility/ExtensionConfiguration87.php
Normal 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]);
|
||||
}
|
||||
}
|
8
Classes/Utility/ExtensionConfigurationInterface.php
Normal file
8
Classes/Utility/ExtensionConfigurationInterface.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Codappix\SearchCore\Utility;
|
||||
|
||||
interface ExtensionConfigurationInterface
|
||||
{
|
||||
public function get($extensionKey);
|
||||
}
|
|
@ -44,7 +44,7 @@ call_user_func(
|
|||
|
||||
|
||||
// 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
|
||||
|| !isset($extensionConfiguration['disable']['elasticsearch'])
|
||||
|
|
Loading…
Reference in a new issue