mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-24 14:56:12 +01:00
TASK: Provide compatible TypoScriptService for both TYPO3 versions
This commit is contained in:
parent
16bc22aa44
commit
9e80574361
7 changed files with 111 additions and 7 deletions
31
Classes/Compatibility/TypoScriptService.php
Normal file
31
Classes/Compatibility/TypoScriptService.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
namespace Codappix\SearchCore\Compatibility;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\TypoScript\TypoScriptService as CoreTypoScriptService;
|
||||
|
||||
/**
|
||||
* Used since TYPO3 CMS 8.7.
|
||||
*/
|
||||
class TypoScriptService extends CoreTypoScriptService implements TypoScriptServiceInterface
|
||||
{
|
||||
|
||||
}
|
31
Classes/Compatibility/TypoScriptService76.php
Normal file
31
Classes/Compatibility/TypoScriptService76.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
namespace Codappix\SearchCore\Compatibility;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Extbase\Service\TypoScriptService as CoreTypoScriptService;
|
||||
|
||||
/**
|
||||
* Used before TYPO3 CMS 8.7.
|
||||
*/
|
||||
class TypoScriptService76 extends CoreTypoScriptService implements TypoScriptServiceInterface
|
||||
{
|
||||
|
||||
}
|
30
Classes/Compatibility/TypoScriptServiceInterface.php
Normal file
30
Classes/Compatibility/TypoScriptServiceInterface.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
namespace Codappix\SearchCore\Compatibility;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Allows to use DI configuration to switch concrete implementation, depending
|
||||
* on current TYPO3 Version.
|
||||
*/
|
||||
interface TypoScriptServiceInterface
|
||||
{
|
||||
public function convertPlainArrayToTypoScriptArray(array $plainArray);
|
||||
}
|
|
@ -20,8 +20,8 @@ namespace Codappix\SearchCore\DataProcessing;
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Codappix\SearchCore\Compatibility\TypoScriptServiceInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
|
||||
/**
|
||||
|
@ -30,11 +30,11 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
|||
class ContentObjectDataProcessorAdapterProcessor implements ProcessorInterface
|
||||
{
|
||||
/**
|
||||
* @var TypoScriptService
|
||||
* @var TypoScriptServiceInterface
|
||||
*/
|
||||
protected $typoScriptService;
|
||||
|
||||
public function __construct(TypoScriptService $typoScriptService)
|
||||
public function __construct(TypoScriptServiceInterface $typoScriptService)
|
||||
{
|
||||
$this->typoScriptService = $typoScriptService;
|
||||
}
|
||||
|
|
|
@ -66,4 +66,9 @@ abstract class AbstractFunctionalTestCase extends CoreTestCase
|
|||
{
|
||||
return ['EXT:search_core/Tests/Functional/Fixtures/BasicSetup.ts'];
|
||||
}
|
||||
|
||||
protected function useLegacyVersion() : bool
|
||||
{
|
||||
return \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < 8000000;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,10 @@ namespace Codappix\SearchCore\Tests\Functional\DataProcessing;
|
|||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Codappix\SearchCore\Compatibility\TypoScriptService76;
|
||||
use Codappix\SearchCore\Compatibility\TypoScriptService;
|
||||
use Codappix\SearchCore\DataProcessing\ContentObjectDataProcessorAdapterProcessor;
|
||||
use Codappix\SearchCore\Tests\Functional\AbstractFunctionalTestCase;
|
||||
use TYPO3\CMS\Extbase\Service\TypoScriptService;
|
||||
use TYPO3\CMS\Frontend\DataProcessing\SplitProcessor;
|
||||
|
||||
class ContentObjectDataProcessorAdapterProcessorTest extends AbstractFunctionalTestCase
|
||||
|
@ -44,7 +45,13 @@ class ContentObjectDataProcessorAdapterProcessorTest extends AbstractFunctionalT
|
|||
'new_content' => ['value1', 'value2'],
|
||||
];
|
||||
|
||||
$subject = new ContentObjectDataProcessorAdapterProcessor(new TypoScriptService);
|
||||
if ($this->useLegacyVersion()) {
|
||||
$typoScriptService = new TypoScriptService76();
|
||||
} else {
|
||||
$typoScriptService = new TypoScriptService();
|
||||
}
|
||||
|
||||
$subject = new ContentObjectDataProcessorAdapterProcessor($typoScriptService);
|
||||
$processedData = $subject->processData($record, $configuration);
|
||||
$this->assertSame(
|
||||
$expectedData,
|
||||
|
|
|
@ -43,12 +43,12 @@ call_user_func(
|
|||
if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 8000000) {
|
||||
$container->registerImplementation(
|
||||
\Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class,
|
||||
\TYPO3\CMS\Core\TypoScript\TypoScriptService::class
|
||||
\Codappix\SearchCore\Compatibility\TypoScriptService::class
|
||||
);
|
||||
} else {
|
||||
$container->registerImplementation(
|
||||
\Codappix\SearchCore\Compatibility\TypoScriptServiceInterface::class,
|
||||
\TYPO3\CMS\Extbase\Service\TypoScriptService::class
|
||||
\Codappix\SearchCore\Compatibility\TypoScriptService76::class
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue