[!!!][TASK] Update for TYPO3 11 & 12

This commit is contained in:
Markus Klein 2023-07-06 16:39:52 +02:00
parent 5cfdc7a6cd
commit 873425c433
16 changed files with 81 additions and 109 deletions

View file

@ -16,7 +16,7 @@ jobs:
php-version: php-version:
- 7.2 - 7.2
- 7.3 - 7.3
- 7.4 - 8.2
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
@ -37,7 +37,7 @@ jobs:
- name: Install PHP - name: Install PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: 7.4 php-version: 8.2
- name: Get Composer Cache Directory - name: Get Composer Cache Directory
id: composer-cache id: composer-cache
@ -55,7 +55,7 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest run: composer install --prefer-dist --no-progress --no-suggest
- name: Check CGL - name: Check CGL
run: ./vendor/bin/phpcs run: .Build/vendor/bin/phpcs
check-dependencies: check-dependencies:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -66,7 +66,7 @@ jobs:
- name: Install PHP - name: Install PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: 7.4 php-version: 8.2
- name: Get Composer Cache Directory - name: Get Composer Cache Directory
id: composer-cache id: composer-cache
@ -80,14 +80,11 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-composer- ${{ runner.os }}-composer-
- name: Keep composer v1 until all dev dependencies are v2 ready
run: sudo composer selfupdate --1
- name: Install dependencies - name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest --no-plugins run: composer require maglnet/composer-require-checker
- name: Missing composer requirements - name: Missing composer requirements
run: ./vendor/bin/composer-require-checker check run: .Build/vendor/bin/composer-require-checker check
xml-linting: xml-linting:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -98,7 +95,7 @@ jobs:
- name: Install PHP - name: Install PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: 7.4 php-version: 8.2
- name: Install xmllint - name: Install xmllint
run: sudo apt-get install libxml2-utils run: sudo apt-get install libxml2-utils
@ -135,8 +132,8 @@ jobs:
strategy: strategy:
matrix: matrix:
php-version: php-version:
- 7.3
- 7.4 - 7.4
- 8.2
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -157,14 +154,11 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-composer- ${{ runner.os }}-composer-
- name: Keep composer v1 until all dev dependencies are v2 ready
run: sudo composer selfupdate --1
- name: Install dependencies - name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest run: composer install --prefer-dist --no-progress --no-suggest
- name: PHPUnit Tests - name: PHPUnit Tests
run: ./vendor/bin/phpunit --testdox run: .Build/vendor/bin/phpunit --testdox
code-quality: code-quality:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -175,7 +169,7 @@ jobs:
- name: Install PHP - name: Install PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: 7.4 php-version: 8.2
- name: Get Composer Cache Directory - name: Get Composer Cache Directory
id: composer-cache id: composer-cache
@ -193,4 +187,4 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest run: composer install --prefer-dist --no-progress --no-suggest
- name: Code Quality (by PHPStan) - name: Code Quality (by PHPStan)
run: ./vendor/bin/phpstan analyse run: .Build/vendor/bin/phpstan analyse

1
.gitignore vendored
View file

@ -1,3 +1,2 @@
/.Build/ /.Build/
/composer.lock /composer.lock
/vendor/

View file

@ -23,6 +23,7 @@ namespace SkillDisplay\SkilldisplayContent\Backend;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Exception;
use SkillDisplay\PHPToolKit\Api\Skill; use SkillDisplay\PHPToolKit\Api\Skill;
use SkillDisplay\PHPToolKit\Api\SkillSet; use SkillDisplay\PHPToolKit\Api\SkillSet;
use TYPO3\CMS\Backend\View\PageLayoutView; use TYPO3\CMS\Backend\View\PageLayoutView;
@ -31,15 +32,8 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
class Preview implements PageLayoutViewDrawItemHookInterface class Preview implements PageLayoutViewDrawItemHookInterface
{ {
/** protected Skill $skillApi;
* @var Skill private SkillSet $skillSetApi;
*/
protected $skillApi;
/**
* @var SkillSet
*/
private $skillSetApi;
public function __construct( public function __construct(
Skill $skillApi, Skill $skillApi,
@ -78,7 +72,7 @@ class Preview implements PageLayoutViewDrawItemHookInterface
foreach ($skills as $skillId) { foreach ($skills as $skillId) {
try { try {
$row['skills'][] = $this->skillApi->getById($skillId); $row['skills'][] = $this->skillApi->getById($skillId);
} catch (\Exception $e) { } catch (Exception $e) {
$row['skills'][]['error'] = $e->getMessage(); $row['skills'][]['error'] = $e->getMessage();
} }
} }
@ -93,7 +87,7 @@ class Preview implements PageLayoutViewDrawItemHookInterface
foreach ($skillSets as $skillSetId) { foreach ($skillSets as $skillSetId) {
try { try {
$row['skillSets'][] = $this->skillSetApi->getById($skillSetId); $row['skillSets'][] = $this->skillSetApi->getById($skillSetId);
} catch (\Exception $e) { } catch (Exception $e) {
$row['skillSets'][]['error'] = $e->getMessage(); $row['skillSets'][]['error'] = $e->getMessage();
} }
} }

View file

@ -28,15 +28,8 @@ use SkillDisplay\PHPToolKit\Api\Campaigns;
class CampaignsFactory class CampaignsFactory
{ {
/** private SettingsFactory $settingsFactory;
* @var SettingsFactory private Client $client;
*/
private $settingsFactory;
/**
* @var Client
*/
private $client;
public function __construct( public function __construct(
SettingsFactory $settingsFactory, SettingsFactory $settingsFactory,

View file

@ -23,6 +23,7 @@ namespace SkillDisplay\SkilldisplayContent\Frontend\DataProcessing;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Exception;
use SkillDisplay\PHPToolKit\Api\SkillSet; use SkillDisplay\PHPToolKit\Api\SkillSet;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@ -30,10 +31,7 @@ use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class SkillSets implements DataProcessorInterface class SkillSets implements DataProcessorInterface
{ {
/** protected SkillSet $skillSetApi;
* @var SkillSet
*/
protected $skillSetApi;
public function __construct( public function __construct(
SkillSet $skillSetApi SkillSet $skillSetApi
@ -50,7 +48,7 @@ class SkillSets implements DataProcessorInterface
$as = $cObj->stdWrapValue('as', $processorConfiguration, 'skillSets'); $as = $cObj->stdWrapValue('as', $processorConfiguration, 'skillSets');
$skillSetIds = GeneralUtility::intExplode( $skillSetIds = GeneralUtility::intExplode(
',', ',',
$cObj->stdWrapValue('skillSets', $processorConfiguration, ''), $cObj->stdWrapValue('skillSets', $processorConfiguration),
true true
); );
$skillSets = []; $skillSets = [];
@ -58,7 +56,7 @@ class SkillSets implements DataProcessorInterface
foreach ($skillSetIds as $skillSetId) { foreach ($skillSetIds as $skillSetId) {
try { try {
$skillSets[] = $this->skillSetApi->getById($skillSetId); $skillSets[] = $this->skillSetApi->getById($skillSetId);
} catch (\Exception $e) { } catch (Exception $e) {
continue; continue;
} }
} }

View file

@ -23,6 +23,7 @@ namespace SkillDisplay\SkilldisplayContent\Frontend\DataProcessing;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Exception;
use SkillDisplay\PHPToolKit\Api\Skill; use SkillDisplay\PHPToolKit\Api\Skill;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
@ -30,10 +31,7 @@ use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;
class Skills implements DataProcessorInterface class Skills implements DataProcessorInterface
{ {
/** protected Skill $skillApi;
* @var Skill
*/
protected $skillApi;
public function __construct( public function __construct(
Skill $skillApi Skill $skillApi
@ -50,7 +48,7 @@ class Skills implements DataProcessorInterface
$as = $cObj->stdWrapValue('as', $processorConfiguration, 'skills'); $as = $cObj->stdWrapValue('as', $processorConfiguration, 'skills');
$skillIds = GeneralUtility::intExplode( $skillIds = GeneralUtility::intExplode(
',', ',',
$cObj->stdWrapValue('skills', $processorConfiguration, ''), $cObj->stdWrapValue('skills', $processorConfiguration),
true true
); );
$skills = []; $skills = [];
@ -58,7 +56,7 @@ class Skills implements DataProcessorInterface
foreach ($skillIds as $skillId) { foreach ($skillIds as $skillId) {
try { try {
$skills[] = $this->skillApi->getById($skillId); $skills[] = $this->skillApi->getById($skillId);
} catch (\Exception $e) { } catch (Exception $e) {
continue; continue;
} }
} }

View file

@ -23,6 +23,7 @@ namespace SkillDisplay\SkilldisplayContent;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use RuntimeException;
use SkillDisplay\PHPToolKit\Configuration\Settings; use SkillDisplay\PHPToolKit\Configuration\Settings;
use TYPO3\CMS\Core\Http\ServerRequest; use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Site\Entity\Site; use TYPO3\CMS\Core\Site\Entity\Site;
@ -30,10 +31,7 @@ use TYPO3\CMS\Core\Site\SiteFinder;
class SettingsFactory class SettingsFactory
{ {
/** private SiteFinder $siteFinder;
* @var SiteFinder
*/
private $siteFinder;
public function __construct( public function __construct(
SiteFinder $siteFinder SiteFinder $siteFinder
@ -45,7 +43,7 @@ class SettingsFactory
{ {
$site = $this->getRequest()->getAttribute('site'); $site = $this->getRequest()->getAttribute('site');
if ($site === null) { if ($site === null) {
throw new \Exception('Could not determine current site.', 1599721652); throw new RuntimeException('Could not determine current site.', 1599721652);
} }
return $this->createFromSite($site); return $this->createFromSite($site);

View file

@ -9,10 +9,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
class TcaEnhancer class TcaEnhancer
{ {
/** private CampaignsFactory $campaignsFactory;
* @var CampaignsFactory
*/
private $campaignsFactory;
public function __construct( public function __construct(
CampaignsFactory $campaignsFactory CampaignsFactory $campaignsFactory

View file

@ -23,6 +23,8 @@ namespace SkillDisplay\SkilldisplayContent\ViewHelpers;
* 02110-1301, USA. * 02110-1301, USA.
*/ */
use Closure;
use Exception;
use SkillDisplay\PHPToolKit\Verification\Link; use SkillDisplay\PHPToolKit\Verification\Link;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
@ -44,10 +46,14 @@ abstract class VerificationViewHelper extends AbstractViewHelper
public static function renderStatic( public static function renderStatic(
array $arguments, array $arguments,
\Closure $renderChildrenClosure, Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext RenderingContextInterface $renderingContext
) { ) {
static::validateIds($arguments); try {
static::validateIds($arguments);
} catch (Exception $e) {
return '';
}
return static::verificationHtml($arguments); return static::verificationHtml($arguments);
} }
@ -55,22 +61,24 @@ abstract class VerificationViewHelper extends AbstractViewHelper
abstract protected static function verificationHtml(array $arguments): string; abstract protected static function verificationHtml(array $arguments): string;
/** /**
* @param array $arguments
* @return void * @return void
* @throws Exception
*/ */
protected static function validateIds(array $arguments) protected static function validateIds(array $arguments): void
{ {
if ( if (
isset($arguments['skill']) && $arguments['skill'] !== '' isset($arguments['skill']) && $arguments['skill'] !== ''
&& isset($arguments['skillSet']) && $arguments['skillSet'] !== '' && isset($arguments['skillSet']) && $arguments['skillSet'] !== ''
) { ) {
throw new \Exception('Can only handle skill or skillSet not both.', 1600775604); throw new Exception('Can only handle skill or skillSet not both.', 1600775604);
} }
if ( if (
(isset($arguments['skill']) === false || $arguments['skill'] === '') (isset($arguments['skill']) === false || $arguments['skill'] === '')
&& (isset($arguments['skillSet']) === false || $arguments['skillSet'] === '') && (isset($arguments['skillSet']) === false || $arguments['skillSet'] === '')
) { ) {
throw new \Exception('Either needs skill or skillSet, none given.', 1600775604); throw new Exception('Either needs skill or skillSet, none given.', 1600775604);
} }
} }

View file

@ -1,9 +1,7 @@
<?php <?php
(function (string $extensionKey, string $tableName) { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile( 'skilldisplay_content',
$extensionKey, 'Configuration/TypoScript/',
'Configuration/TypoScript/', 'SkillDisplay'
'SkillDisplay' );
);
})('skilldisplay_content', 'sys_template');

View file

@ -1,9 +1,9 @@
<?php <?php
(function (string $extensionKey, string $tableName) { (function (string $extensionKey) {
$languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:' . $tableName . '.'; $languagePath = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_tca.xlf:tt_content.';
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA'][$tableName], [ \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($GLOBALS['TCA']['tt_content'], [
'columns' => [ 'columns' => [
'CType' => [ 'CType' => [
'config' => [ 'config' => [
@ -13,7 +13,7 @@
], ],
], ],
'skilldisplay_skills' => [ 'skilldisplay_skills' => [
'exclude' => 1, 'exclude' => true,
'label' => $languagePath . 'skilldisplay_skills', 'label' => $languagePath . 'skilldisplay_skills',
'description' => $languagePath . 'skilldisplay_skills.description', 'description' => $languagePath . 'skilldisplay_skills.description',
'config' => [ 'config' => [
@ -23,7 +23,7 @@
], ],
], ],
'skilldisplay_skillset' => [ 'skilldisplay_skillset' => [
'exclude' => 1, 'exclude' => true,
'label' => $languagePath . 'skilldisplay_skillset', 'label' => $languagePath . 'skilldisplay_skillset',
'description' => $languagePath . 'skilldisplay_skillset.description', 'description' => $languagePath . 'skilldisplay_skillset.description',
'config' => [ 'config' => [
@ -33,17 +33,16 @@
], ],
], ],
'skilldisplay_campaign' => [ 'skilldisplay_campaign' => [
'exclude' => 1, 'exclude' => true,
'label' => $languagePath . 'skilldisplay_campaign', 'label' => $languagePath . 'skilldisplay_campaign',
'description' => $languagePath . 'skilldisplay_campaign.description', 'description' => $languagePath . 'skilldisplay_campaign.description',
'config' => [ 'config' => [
'type' => 'select', 'type' => 'select',
'renderType' => 'selectSingle', 'renderType' => 'selectSingle',
'itemsProcFunc' => \SkillDisplay\SkilldisplayContent\TcaEnhancer::class 'itemsProcFunc' => \SkillDisplay\SkilldisplayContent\TcaEnhancer::class . '->' . 'getCampaignsForTCA',
. '->' . 'getCampaignsForTCA',
'items' => [] 'items' => []
] ]
], ],
], ],
]); ]);
})('skilldisplay_content', 'tt_content'); })('skilldisplay_content');

View file

@ -1,4 +1,4 @@
tt_content.skilldisplay_skills = < lib.contentElement tt_content.skilldisplay_skills =< lib.contentElement
tt_content.skilldisplay_skills { tt_content.skilldisplay_skills {
templateName = SkillDisplaySkills templateName = SkillDisplaySkills
@ -10,7 +10,7 @@ tt_content.skilldisplay_skills {
} }
} }
tt_content.skilldisplay_skillset = < lib.contentElement tt_content.skilldisplay_skillset =< lib.contentElement
tt_content.skilldisplay_skillset { tt_content.skilldisplay_skillset {
templateName = SkillDisplaySkillSet templateName = SkillDisplaySkillSet
@ -22,8 +22,3 @@ tt_content.skilldisplay_skillset {
} }
} }
page {
includeCSS {
skilldisplay = EXT:skilldisplay_content/Resources/Public/Css/Styles.css
}
}

View file

@ -21,8 +21,7 @@ Right now it provides the following features:
Installation Installation
============ ============
The extension can be installed by downloading recent version from GitHub and adding Install the extension via Extension Manager or composer.
it inside `typo3conf/` folder.
Add static TypoScript once installed and activated via Extension Manager. Add static TypoScript once installed and activated via Extension Manager.
The TypoScript contains the rendering definition for provided content elements. The TypoScript contains the rendering definition for provided content elements.
@ -47,6 +46,11 @@ Or copy the files from `/Resources/Private/Templates/ContentElements/` to your e
Configuration Configuration
============= =============
You may include default CSS for the templates in your TypoScript::
page.includeCSS.skilldisplay = EXT:skilldisplay_content/Resources/Public/Css/Styles.css
Site configuration is extended, where options like API Key can be provided. Site configuration is extended, where options like API Key can be provided.
Also TypoScript and TSconfig is added to provide wizard entries for new content elements, as well as rendering. Also TypoScript and TSconfig is added to provide wizard entries for new content elements, as well as rendering.

View file

@ -26,40 +26,36 @@
} }
}, },
"require": { "require": {
"php": "7.2.* || 7.3.* || 7.4.*", "php": "^7.4 || ^8.1 || ^8.2",
"typo3/cms-core": "^10.4", "skilldisplay/phptoolkit": "^2.0",
"skilldisplay/phptoolkit": "^1.2.3", "typo3/cms-backend": "^11.5 || ^12.4",
"typo3/cms-backend": "^10.4", "typo3/cms-frontend": "^11.5 || ^12.4"
"typo3/cms-frontend": "^10.4",
"typo3fluid/fluid": "^2.6",
"guzzlehttp/guzzle": "^6.5"
}, },
"require-dev": { "require-dev": {
"squizlabs/php_codesniffer": "^3.5", "squizlabs/php_codesniffer": "^3.5",
"phpstan/phpstan": "^0.12.18", "phpstan/phpstan": "^0.12.18",
"phpstan/phpstan-phpunit": "*", "phpstan/phpstan-phpunit": "*",
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.0",
"maglnet/composer-require-checker": "^2.1",
"saschaegerer/phpstan-typo3": "^0.13.1", "saschaegerer/phpstan-typo3": "^0.13.1",
"typo3/testing-framework": "^6.4", "typo3/testing-framework": "^7",
"phpspec/prophecy-phpunit": "^2", "phpspec/prophecy-phpunit": "^2",
"jangregor/phpstan-prophecy": "^0.8.0" "jangregor/phpstan-prophecy": "^0.8.0"
}, },
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"post-autoload-dump": [
"TYPO3\\TestingFramework\\Composer\\ExtensionTestEnvironment::prepare"
]
},
"extra": { "extra": {
"typo3/cms": { "typo3/cms": {
"cms-package-dir": "{$vendor-dir}/typo3/cms",
"extension-key": "skilldisplay_content", "extension-key": "skilldisplay_content",
"web-dir": ".Build/web" "web-dir": ".Build/web"
}, },
"branch-alias": { "branch-alias": {
"dev-main": "2.0.x-dev" "dev-main": "3.x-dev"
}
},
"config": {
"vendor-dir": ".Build/vendor",
"allow-plugins": {
"typo3/cms-composer-installers": true,
"typo3/class-alias-loader": true,
"phpstan/extension-installer": true
} }
} }
} }

View file

@ -11,10 +11,10 @@ $EM_CONF[$_EXTKEY] = [
'author' => 'Daniel Siepmann', 'author' => 'Daniel Siepmann',
'author_email' => 'coding@daniel-siepmann.de', 'author_email' => 'coding@daniel-siepmann.de',
'author_company' => '', 'author_company' => '',
'version' => '2.0.3', 'version' => '3.0.0',
'constraints' => [ 'constraints' => [
'depends' => [ 'depends' => [
'typo3' => '10.4.0-10.4.99', 'typo3' => '11.5.0-12.4.99',
], ],
'conflicts' => [], 'conflicts' => [],
'suggests' => [], 'suggests' => [],

View file

@ -22,6 +22,7 @@
); );
} }
// todo v11?
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][$extKey] = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][$extKey] =
\SkillDisplay\SkilldisplayContent\Backend\Preview::class; \SkillDisplay\SkilldisplayContent\Backend\Preview::class;
})('skilldisplay_content'); })('skilldisplay_content');