From 9c64c1ba33a356ae5b39312a0e8acc742a60d872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nitzsche?= Date: Sun, 23 Jul 2023 17:32:38 +0200 Subject: [PATCH] Fixes #31 upgrade for TYPO3 12.4 LTS * #31 upgrade for TYPO3 12.4 LTS * #31 refactor indexer services * #31 fix plugin rendering --- ChangeLog.md | 3 + Classes/Action/PlayerStats.php | 6 +- .../DependencyInjection/StatsIndexerPass.php | 29 ++++++ Classes/Hooks/ClearStats.php | 14 ++- Classes/Hooks/Marker.php | 24 +++-- Classes/Service/Statistics.php | 70 +++++++-------- Classes/Service/StatsIndexerProvider.php | 74 +++++++++++++++ Classes/Service/StatsServiceRegistry.php | 14 ++- Classes/StatsIndexer/CoachStats.php | 10 ++- Classes/StatsIndexer/CoachStatsInterface.php | 50 +++++++++++ Classes/StatsIndexer/PlayerGoalStats.php | 10 ++- Classes/StatsIndexer/PlayerStats.php | 10 ++- Classes/StatsIndexer/PlayerStatsInterface.php | 50 +++++++++++ Classes/StatsIndexer/PlayerTimeStats.php | 10 ++- Classes/StatsIndexer/RefereeStats.php | 10 ++- .../StatsIndexer/RefereeStatsInterface.php | 50 +++++++++++ Classes/StatsIndexer/StatsInterface.php | 37 ++++++++ Classes/Utility/StatsDataBag.php | 2 +- Classes/View/CoachStats.php | 9 +- Classes/View/DBStats.php | 9 +- Classes/View/PlayerStats.php | 16 ++-- Classes/View/RefereeStats.php | 9 +- .../{modWizards.ts => modWizards.tsconfig} | 0 ...moduleConfig.tss => moduleConfig.tsconfig} | 0 Configuration/Services.php | 12 +++ Configuration/Services.yaml | 13 +++ Configuration/TCA/Overrides/sys_template.php | 4 +- Configuration/TCA/Overrides/tt_content.php | 4 +- .../Overrides/tx_cfcleague_competition.php | 2 +- Configuration/TCA/tx_t3sportstats_tags.php | 2 +- Configuration/page.tsconfig | 2 + Documentation/capital/plugin_advanced.md | 2 +- Documentation/capital/technical_notes.md | 7 +- README.md | 3 +- composer.json | 8 +- ext_emconf.php | 10 +-- ext_localconf.php | 90 ++++--------------- ext_tables.php | 8 +- 38 files changed, 503 insertions(+), 180 deletions(-) create mode 100644 Classes/DependencyInjection/StatsIndexerPass.php create mode 100644 Classes/Service/StatsIndexerProvider.php create mode 100644 Classes/StatsIndexer/CoachStatsInterface.php create mode 100644 Classes/StatsIndexer/PlayerStatsInterface.php create mode 100644 Classes/StatsIndexer/RefereeStatsInterface.php create mode 100644 Classes/StatsIndexer/StatsInterface.php rename Configuration/PageTS/{modWizards.ts => modWizards.tsconfig} (100%) rename Configuration/PageTS/{moduleConfig.tss => moduleConfig.tsconfig} (100%) create mode 100644 Configuration/Services.php create mode 100644 Configuration/Services.yaml create mode 100644 Configuration/page.tsconfig diff --git a/ChangeLog.md b/ChangeLog.md index 66b1300..d732702 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,9 @@ Changelog ---------- +v1.5.0 (??.07.2023) + * Add support for TYPO3 12.4 LTS + v1.4.0 (21.07.2023) * Add support for TYPO3 11.5 LTS and PHP 8.x * Fix PHP warning diff --git a/Classes/Action/PlayerStats.php b/Classes/Action/PlayerStats.php index 6d0f8c3..c9c518f 100755 --- a/Classes/Action/PlayerStats.php +++ b/Classes/Action/PlayerStats.php @@ -16,7 +16,7 @@ /*************************************************************** * Copyright notice * - * (c) 2010-2022 Rene Nitzsche (rene@system25.de) + * (c) 2010-2023 Rene Nitzsche (rene@system25.de) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -114,7 +114,7 @@ private function findData(RequestInterface $request, $viewData, $type) * * @param string $confid * Die Confid des PageBrowsers. z.B. myview.org.pagebrowser ohne Punkt! - * @param \tx_rnbase_configurations $configurations + * @param ConfigurationInterface $configurations * @param \ArrayObject $viewdata * @param array $fields * @param array $options @@ -124,7 +124,7 @@ private static function handlePageBrowser(ConfigurationInterface $configurations $confid .= '.'; if (is_array($configurations->get($confid))) { // Die Gesamtzahl der Items ist entweder im Limit gesetzt oder muss ermittelt werden - $listSize = intval($options['limit']); + $listSize = (int) ($options['limit'] ?? 0); if (!$listSize) { // Mit Pagebrowser benötigen wir zwei Zugriffe, um die Gesamtanzahl der Items zu ermitteln $options['count'] = 1; diff --git a/Classes/DependencyInjection/StatsIndexerPass.php b/Classes/DependencyInjection/StatsIndexerPass.php new file mode 100644 index 0000000..cb724bb --- /dev/null +++ b/Classes/DependencyInjection/StatsIndexerPass.php @@ -0,0 +1,29 @@ +has(StatsIndexerProvider::class)) { + return; + } + + $definition = $container->findDefinition(StatsIndexerProvider::class); + + // find all service IDs with the t3sports.stats.player tag + $taggedServices = $container->findTaggedServiceIds('t3sports.stats.indexer'); + + foreach ($taggedServices as $id => $tags) { + // add the indexer to the IndexerProvider service + $definition->addMethodCall('addStatsIndexer', [new Reference($id)]); + } + } +} diff --git a/Classes/Hooks/ClearStats.php b/Classes/Hooks/ClearStats.php index 8dbb4df..21aaec5 100644 --- a/Classes/Hooks/ClearStats.php +++ b/Classes/Hooks/ClearStats.php @@ -3,13 +3,13 @@ namespace System25\T3sports\Hooks; use System25\T3sports\Model\Competition; -use System25\T3sports\Service\StatsServiceRegistry; +use System25\T3sports\Service\Statistics; use tx_rnbase; /*************************************************************** * Copyright notice * - * (c) 2010-2022 Rene Nitzsche + * (c) 2010-2023 Rene Nitzsche * Contact: rene@system25.de * All rights reserved * @@ -33,13 +33,19 @@ */ class ClearStats { + private $statsSrv; + + public function __construct(Statistics $statisticsService = null) + { + $this->statsSrv = $statisticsService ?: new Statistics(); + } + public function clearStats4Comp($params, $parent) { - $srv = (new StatsServiceRegistry())->getStatisticService(); /* @var $comp Competition */ $comp = tx_rnbase::makeInstance(Competition::class, $params['compUid']); if ($comp && $comp->isValid()) { - $srv->indexPlayerStatsByCompetition($comp); + $this->statsSrv->indexPlayerStatsByCompetition($comp); } } } diff --git a/Classes/Hooks/Marker.php b/Classes/Hooks/Marker.php index 023b476..55fb01f 100644 --- a/Classes/Hooks/Marker.php +++ b/Classes/Hooks/Marker.php @@ -9,13 +9,13 @@ use System25\T3sports\Frontend\Marker\ProfileMarker; use System25\T3sports\Marker\PlayerStatsMarker; use System25\T3sports\Model\Profile; -use System25\T3sports\Service\StatsServiceRegistry; +use System25\T3sports\Service\Statistics; use tx_rnbase; /*************************************************************** * Copyright notice * - * (c) 2008-2022 Rene Nitzsche + * (c) 2008-2023 Rene Nitzsche * Contact: rene@system25.de * All rights reserved * @@ -59,6 +59,13 @@ class Marker ], ]; + private $statsSrv; + + public function __construct(Statistics $statisticsService = null) + { + $this->statsSrv = $statisticsService ?: new Statistics(); + } + /** * Extend profileMarker for statistical data about profile. * @@ -93,7 +100,7 @@ public function parseProfile($params, $parent) $markerClass = $markerClass ? $markerClass : PlayerStatsMarker::class; $marker = tx_rnbase::makeInstance($markerClass); // Wir sollten nur einen Datensatz haben und können diesen jetzt ausgeben - $subpartArray['###'.$subpartMarker.'###'] = $marker->parseTemplate($subpart, $items[0], $config->getFormatter(), $confId.$statKey.'.data.', $subpartMarker); + $subpartArray['###'.$subpartMarker.'###'] = $marker->parseTemplate($subpart, $items[0] ?? null, $config->getFormatter(), $confId.$statKey.'.data.', $subpartMarker); } $params['template'] = Templates::substituteMarkerArrayCached($template, [], $subpartArray); @@ -101,17 +108,16 @@ public function parseProfile($params, $parent) /** * @param Profile $profile - * @param unknown $configurations - * @param unknown $confId - * @param unknown $type + * @param ConfigurationInterface $configurations + * @param string $confId + * @param string $type * * @throws \Exception * - * @return unknown + * @return array */ private function findData(Profile $profile, ConfigurationInterface $configurations, $confId, $type) { - $srv = (new StatsServiceRegistry())->getStatisticService(); $request = new Request($configurations->getParameters(), $configurations, $confId); $confId = $confId.$type.'.'; $filter = BaseFilter::createFilter( @@ -136,7 +142,7 @@ private function findData(Profile $profile, ConfigurationInterface $configuratio $filter->init($fields, $options); $searchMethod = self::$filterData[$filterType]['search']; - $items = $srv->$searchMethod($fields, $options); + $items = $this->statsSrv->$searchMethod($fields, $options); return $items; } diff --git a/Classes/Service/Statistics.php b/Classes/Service/Statistics.php index 2db017f..17282ac 100644 --- a/Classes/Service/Statistics.php +++ b/Classes/Service/Statistics.php @@ -4,16 +4,16 @@ use Sys25\RnBase\Database\Connection; use Sys25\RnBase\Search\SearchBase; -use Sys25\RnBase\Typo3Wrapper\Service\AbstractService; use Sys25\RnBase\Utility\Dates; use Sys25\RnBase\Utility\Logger; -use Sys25\RnBase\Utility\Misc; use Sys25\RnBase\Utility\Strings; use System25\T3sports\Model\Competition; use System25\T3sports\Model\Fixture; +use System25\T3sports\Model\Team; use System25\T3sports\Search\SearchCoachStats; use System25\T3sports\Search\SearchPlayerStats; use System25\T3sports\Search\SearchRefereeStats; +use System25\T3sports\StatsIndexer\PlayerStatsInterface; use System25\T3sports\Utility\ServiceRegistry; use System25\T3sports\Utility\StatsDataBag; use System25\T3sports\Utility\StatsMatchNoteProvider; @@ -47,29 +47,35 @@ * * @author Rene Nitzsche */ -class Statistics extends AbstractService +class Statistics { - private $statsSrvArr = []; + private $matchService; + private $indexerProvider; + + public function __construct(MatchService $matchService = null, StatsIndexerProvider $indexerProvider = null) + { + $this->matchService = $matchService ?: ServiceRegistry::getMatchService(); + $this->indexerProvider = $indexerProvider ?: StatsIndexerProvider::getInstance(); + } /** * Update statistics for a competition. * * @param Competition $competition */ - public function indexPlayerStatsByCompetition($competition) + public function indexPlayerStatsByCompetition(Competition $competition) { // Der Service lädt alle DatenServices für Spielerdaten // Danach lädt er die Spiele eines Wettbewerbs // Für jedes Spiel werden die Events geladen // Anschließend bekommt jeder Service das Spiel, den Spieler und die Events übergeben // In ein Datenarray legt er die relevanten Daten für den Spieler - $mSrv = ServiceRegistry::getMatchService(); - $builder = $mSrv->getMatchTableBuilder(); + $builder = $this->matchService->getMatchTableBuilder(); $builder->setCompetitions($competition->getUid()); $builder->setStatus(2); $fields = $options = []; $builder->getFields($fields, $options); - $matches = $mSrv->search($fields, $options); + $matches = $this->matchService->search($fields, $options); $this->indexStatsByMatches($matches); } @@ -111,7 +117,7 @@ public function indexStatsByMatches($matches) * @param StatsMatchNoteProvider $mnProv * @param bool $homeTeam */ - private function indexPlayerData($match, $mnProv, $homeTeam) + private function indexPlayerData(Fixture $match, $mnProv, $homeTeam) { // Services laden $servicesArr = $this->lookupPlayerServices(); @@ -138,7 +144,7 @@ private function indexPlayerData($match, $mnProv, $homeTeam) * @param StatsMatchNoteProvider $mnProv * @param bool $homeTeam */ - private function indexCoachData($match, $mnProv, $homeTeam) + private function indexCoachData(Fixture $match, $mnProv, $homeTeam) { // Services laden $servicesArr = $this->lookupCoachServices(); @@ -165,7 +171,7 @@ private function indexCoachData($match, $mnProv, $homeTeam) * @param StatsMatchNoteProvider $mnProv * @param bool $homeTeam */ - private function indexRefereeData($match, $mnProv, $homeTeam) + private function indexRefereeData(Fixture $match, $mnProv, $homeTeam) { // Services laden $servicesArr = $this->lookupRefereeServices(); @@ -189,7 +195,7 @@ private function indexRefereeData($match, $mnProv, $homeTeam) * * @param Fixture $match */ - private function clearPlayerData($match, $isHome) + private function clearPlayerData(Fixture $match, $isHome) { $where = 't3match = '.$match->getUid().' AND ishome='.($isHome ? 1 : 0); @@ -201,7 +207,7 @@ private function clearPlayerData($match, $isHome) * * @param Fixture $match */ - private function clearCoachData($match, $isHome) + private function clearCoachData(Fixture $match, $isHome) { $where = 't3match = '.$match->getUid().' AND ishome='.($isHome ? 1 : 0); @@ -213,7 +219,7 @@ private function clearCoachData($match, $isHome) * * @param Fixture $match */ - private function clearRefereeData($match, $isHome) + private function clearRefereeData(Fixture $match, $isHome) { $where = 't3match = '.$match->getUid().' AND ishome='.($isHome ? 1 : 0); @@ -254,10 +260,9 @@ private function saveRefereeData($dataBags) * Liefert die DataBags für die Spieler eines beteiligten Teams. * * @param Fixture $match - * @param bool $home - * true, wenn das Heimteam geholt werden soll + * @param bool $home true, wenn das Heimteam geholt werden soll * - * @return array[StatsDataBag] + * @return StatsDataBag[] */ public function getPlayerBags($match, $home) { @@ -288,10 +293,9 @@ public function getPlayerBags($match, $home) * Liefert die DataBags für die Trainer eines beteiligten Teams. * * @param Fixture $match - * @param bool $home - * true, wenn das Heimteam geholt werden soll + * @param bool $home true, wenn das Heimteam geholt werden soll * - * @return array[StatsDataBag] + * @return StatsDataBag[] */ public function getCoachBags($match, $home) { @@ -311,12 +315,11 @@ public function getCoachBags($match, $home) * Liefert die DataBags für den Schiedsrichter eines Spiels. * * @param Fixture $match - * @param bool $home - * true, wenn das Heimteam geholt werden soll + * @param bool $home true, wenn das Heimteam geholt werden soll * - * @return array[StatsDataBag] + * @return StatsDataBag[]] */ - public function getRefereeBags($match, $home) + public function getRefereeBags(Fixture $match, $home) { $refereeUid = $match->getProperty('referee'); $ids = $match->getProperty('referee'); @@ -350,10 +353,13 @@ public function getRefereeBags($match, $home) * @param bool $home * @param string $profileField * - * @return object|\Exception + * @return StatsDataBag + * + * @throws \Exception */ private function createProfileBag($uid, $match, $home, $profileField) { + /** @var StatsDataBag $bag */ $bag = tx_rnbase::makeInstance(StatsDataBag::class); $bag->setParentUid($uid); // Hier noch die allgemeinen Daten rein! @@ -378,7 +384,7 @@ private function createProfileBag($uid, $match, $home, $profileField) return $bag; } - private function getGroupUid($team, $competition) + private function getGroupUid(Team $team, Competition $competition) { $groupUid = $team->getGroupUid(); if (!$groupUid) { @@ -440,7 +446,7 @@ public function searchRefereeStats($fields, $options) */ public function lookupPlayerServices() { - return $this->lookupStatsServices('t3sportsPlayerStats'); + return $this->lookupStatsServices(PlayerStatsInterface::INDEXER_TYPE); } /** @@ -470,14 +476,8 @@ public function lookupRefereeServices() */ private function lookupStatsServices($key) { - if (!array_key_exists($key, $this->statsSrvArr)) { - $srvArr = Misc::lookupServices($key); - $this->statsSrvArr[$key] = []; - foreach ($srvArr as $subType => $srvData) { - $this->statsSrvArr[$key][] = Misc::getService($key, $subType); - } - } + $indexer = $this->indexerProvider->getStatsIndexerByType($key); - return $this->statsSrvArr[$key]; + return $indexer; } } diff --git a/Classes/Service/StatsIndexerProvider.php b/Classes/Service/StatsIndexerProvider.php new file mode 100644 index 0000000..0ca5a56 --- /dev/null +++ b/Classes/Service/StatsIndexerProvider.php @@ -0,0 +1,74 @@ +getIndexerType(); + if (!isset($this->statsIndexer[$type])) { + $this->statsIndexer[$type] = []; + } + $this->statsIndexer[$type][] = $indexer; + } + + /** + * @return StatsInterface[] + */ + public function getStatsIndexerByType(string $type) + { + return $this->statsIndexer[$type] ?? []; + } + + /** + * Only used by T3 versions prior to 10.x. + * + * @return StatsIndexerProvider + */ + public static function getInstance() + { + if (null === self::$instance) { + self::$instance = new self(); + } + + return self::$instance; + } +} diff --git a/Classes/Service/StatsServiceRegistry.php b/Classes/Service/StatsServiceRegistry.php index 8988232..6f072d7 100644 --- a/Classes/Service/StatsServiceRegistry.php +++ b/Classes/Service/StatsServiceRegistry.php @@ -5,7 +5,7 @@ /*************************************************************** * Copyright notice * -* (c) 2010-2020 Rene Nitzsche (rene@system25.de) +* (c) 2010-2023 Rene Nitzsche (rene@system25.de) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -28,8 +28,16 @@ /** * Zentrale Klasse für den Zugriff auf verschiedene Services. */ -class StatsServiceRegistry +class StatsServiceRegistry implements \TYPO3\CMS\Core\SingletonInterface { + private $statisticsService; + + public function __construct( + Statistics $statisticsService = null + ) { + $this->statisticsService = $statisticsService ?: new Statistics(); + } + /** * Liefert den Statistik-Service. * @@ -37,6 +45,6 @@ class StatsServiceRegistry */ public function getStatisticService() { - return \tx_rnbase_util_Misc::getService('t3sportstats', 'statistics'); + return $this->statisticsService; } } diff --git a/Classes/StatsIndexer/CoachStats.php b/Classes/StatsIndexer/CoachStats.php index e828911..88c6296 100644 --- a/Classes/StatsIndexer/CoachStats.php +++ b/Classes/StatsIndexer/CoachStats.php @@ -2,7 +2,6 @@ namespace System25\T3sports\StatsIndexer; -use Sys25\RnBase\Typo3Wrapper\Service\AbstractService; use Sys25\RnBase\Utility\Strings; use System25\T3sports\Model\Fixture; use System25\T3sports\Utility\StatsConfig; @@ -35,10 +34,15 @@ /** * @author Rene Nitzsche */ -class CoachStats extends AbstractService +class CoachStats implements CoachStatsInterface { private $types = []; + public function getIndexerType() + { + return self::INDEXER_TYPE; + } + /** * Update statistics for a coach. * @@ -47,7 +51,7 @@ class CoachStats extends AbstractService * @param StatsMatchNoteProvider $mnProv * @param bool $isHome */ - public function indexCoachStats($dataBag, $match, $mnProv, $isHome) + public function indexCoachStats(StatsDataBag $dataBag, Fixture $match, StatsMatchNoteProvider $mnProv, bool $isHome) { // Wir betrachten das Spiel für einen bestimmten Spieler $this->indexSimple($dataBag, $mnProv, $isHome); diff --git a/Classes/StatsIndexer/CoachStatsInterface.php b/Classes/StatsIndexer/CoachStatsInterface.php new file mode 100644 index 0000000..129d824 --- /dev/null +++ b/Classes/StatsIndexer/CoachStatsInterface.php @@ -0,0 +1,50 @@ +getParentUid(); diff --git a/Classes/StatsIndexer/PlayerStats.php b/Classes/StatsIndexer/PlayerStats.php index f91e94e..d3d5f80 100644 --- a/Classes/StatsIndexer/PlayerStats.php +++ b/Classes/StatsIndexer/PlayerStats.php @@ -2,7 +2,6 @@ namespace System25\T3sports\StatsIndexer; -use Sys25\RnBase\Typo3Wrapper\Service\AbstractService; use Sys25\RnBase\Utility\Strings; use System25\T3sports\Model\Fixture; use System25\T3sports\Utility\StatsConfig; @@ -35,10 +34,15 @@ /** * @author Rene Nitzsche */ -class PlayerStats extends AbstractService +class PlayerStats implements PlayerStatsInterface { private $types = []; + public function getIndexerType() + { + return self::INDEXER_TYPE; + } + /** * Update statistics for a player. * @@ -47,7 +51,7 @@ class PlayerStats extends AbstractService * @param StatsMatchNoteProvider $mnProv * @param bool $isHome */ - public function indexPlayerStats($dataBag, $match, $mnProv, $isHome) + public function indexPlayerStats(StatsDataBag $dataBag, Fixture $match, StatsMatchNoteProvider $mnProv, bool $isHome) { // Wir betrachten das Spiel für einen bestimmten Spieler $this->indexSimple($dataBag, $mnProv); diff --git a/Classes/StatsIndexer/PlayerStatsInterface.php b/Classes/StatsIndexer/PlayerStatsInterface.php new file mode 100644 index 0000000..543e648 --- /dev/null +++ b/Classes/StatsIndexer/PlayerStatsInterface.php @@ -0,0 +1,50 @@ +serviceLocator = $locator ? $locator : new ServiceLocator(); } + public function getIndexerType() + { + return self::INDEXER_TYPE; + } + /** * Update statistics for a player * playtime, played. @@ -56,7 +60,7 @@ public function __construct(ServiceLocator $locator = null) * @param Fixture $match * @param StatsMatchNoteProvider $mnProv */ - public function indexPlayerStats($dataBag, $match, $mnProv, $isHome) + public function indexPlayerStats(StatsDataBag $dataBag, Fixture $match, StatsMatchNoteProvider $mnProv, bool $isHome) { // Wir betrachten das Spiel für einen bestimmten Spieler $profId = $dataBag->getParentUid(); diff --git a/Classes/StatsIndexer/RefereeStats.php b/Classes/StatsIndexer/RefereeStats.php index 6453448..eaca165 100644 --- a/Classes/StatsIndexer/RefereeStats.php +++ b/Classes/StatsIndexer/RefereeStats.php @@ -2,7 +2,6 @@ namespace System25\T3sports\StatsIndexer; -use Sys25\RnBase\Typo3Wrapper\Service\AbstractService; use Sys25\RnBase\Utility\Strings; use System25\T3sports\Model\Fixture; use System25\T3sports\Utility\StatsConfig; @@ -39,10 +38,15 @@ * * @author Rene Nitzsche */ -class RefereeStats extends AbstractService +class RefereeStats implements RefereeStatsInterface { private $types = []; + public function getIndexerType() + { + return self::INDEXER_TYPE; + } + /** * Update statistics for a referee. * @@ -51,7 +55,7 @@ class RefereeStats extends AbstractService * @param StatsMatchNoteProvider $mnProv * @param bool $isHome */ - public function indexRefereeStats($dataBag, $match, $mnProv, $isHome) + public function indexRefereeStats(StatsDataBag $dataBag, Fixture $match, StatsMatchNoteProvider $mnProv, bool $isHome) { // Wir betrachten das Spiel für einen bestimmten SR if (!$this->isAssist($dataBag)) { diff --git a/Classes/StatsIndexer/RefereeStatsInterface.php b/Classes/StatsIndexer/RefereeStatsInterface.php new file mode 100644 index 0000000..746cba0 --- /dev/null +++ b/Classes/StatsIndexer/RefereeStatsInterface.php @@ -0,0 +1,50 @@ +data[$type] = intval($this->data[$type]) + $value; + $this->data[$type] = intval($this->data[$type] ?? 0) + $value; } public function setType($type, $value) diff --git a/Classes/View/CoachStats.php b/Classes/View/CoachStats.php index ed8069f..876ef09 100644 --- a/Classes/View/CoachStats.php +++ b/Classes/View/CoachStats.php @@ -2,15 +2,18 @@ namespace System25\T3sports\View; +use Sys25\RnBase\Frontend\Marker\ListBuilder; +use Sys25\RnBase\Frontend\Marker\Templates; use Sys25\RnBase\Frontend\Request\RequestInterface; use Sys25\RnBase\Frontend\View\ContextInterface; use Sys25\RnBase\Frontend\View\Marker\BaseView; use System25\T3sports\Marker\CoachStatsMarker; +use tx_rnbase; /*************************************************************** * Copyright notice * - * (c) 2010-2020 Rene Nitzsche (rene@system25.de) + * (c) 2010-2023 Rene Nitzsche (rene@system25.de) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -40,11 +43,11 @@ protected function createOutput($template, RequestInterface $request, $formatter $viewData = $request->getViewContext(); $items = &$viewData->offsetGet('items'); - $listBuilder = \tx_rnbase::makeInstance('tx_rnbase_util_ListBuilder'); + $listBuilder = tx_rnbase::makeInstance(ListBuilder::class); $out = ''; foreach ($items as $type => $data) { - $subTemplate = \tx_rnbase_util_Templates::getSubpart($template, '###'.strtoupper($type).'###'); + $subTemplate = Templates::getSubpart($template, '###'.strtoupper($type).'###'); $out .= $listBuilder->render($data, $viewData, $subTemplate, CoachStatsMarker::class, $request ->getConfId().$type.'.data.', 'DATA', $formatter); } diff --git a/Classes/View/DBStats.php b/Classes/View/DBStats.php index a7094bd..d472928 100644 --- a/Classes/View/DBStats.php +++ b/Classes/View/DBStats.php @@ -2,6 +2,7 @@ namespace System25\T3sports\View; +use Sys25\RnBase\Frontend\Marker\Templates; use Sys25\RnBase\Frontend\Request\RequestInterface; use Sys25\RnBase\Frontend\View\ContextInterface; use Sys25\RnBase\Frontend\View\Marker\BaseView; @@ -9,7 +10,7 @@ /*************************************************************** * Copyright notice * - * (c) 2010-2020 Rene Nitzsche (rene@system25.de) + * (c) 2010-2023 Rene Nitzsche (rene@system25.de) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -46,13 +47,13 @@ protected function createOutput($template, RequestInterface $request, $formatter $subpartArr = []; foreach ($items as $table => $data) { $tableMarker = '###'.strtoupper($table).'###'; - $subpart = \tx_rnbase_util_Templates::getSubpart($template, $tableMarker); + $subpart = Templates::getSubpart($template, $tableMarker); // Jetzt die Tabelle rein $markerArr = $formatter->getItemMarkerArrayWrapped($data, $request ->getConfId().$table.'.', 0, strtoupper($table).'_'); - $subpartArr[$tableMarker] = \tx_rnbase_util_Templates::substituteMarkerArrayCached($subpart, $markerArr); + $subpartArr[$tableMarker] = Templates::substituteMarkerArrayCached($subpart, $markerArr); } - $out = \tx_rnbase_util_Templates::substituteMarkerArrayCached($template, [], $subpartArr); + $out = Templates::substituteMarkerArrayCached($template, [], $subpartArr); return $out; } diff --git a/Classes/View/PlayerStats.php b/Classes/View/PlayerStats.php index f7b7ec1..70c23e9 100755 --- a/Classes/View/PlayerStats.php +++ b/Classes/View/PlayerStats.php @@ -2,15 +2,19 @@ namespace System25\T3sports\View; +use Sys25\RnBase\Frontend\Marker\ListBuilder; +use Sys25\RnBase\Frontend\Marker\Templates; use Sys25\RnBase\Frontend\Request\RequestInterface; use Sys25\RnBase\Frontend\View\ContextInterface; use Sys25\RnBase\Frontend\View\Marker\BaseView; +use Sys25\RnBase\Utility\Strings; use System25\T3sports\Marker\PlayerStatsMarker; +use tx_rnbase; /*************************************************************** * Copyright notice * - * (c) 2010-2020 Rene Nitzsche (rene@system25.de) + * (c) 2010-2023 Rene Nitzsche (rene@system25.de) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -42,10 +46,10 @@ protected function createOutput($template, RequestInterface $request, $formatter $configurations = $request->getConfigurations(); $viewData = $request->getViewContext(); $items = &$viewData->offsetGet('items'); - $listBuilder = \tx_rnbase::makeInstance('tx_rnbase_util_ListBuilder'); - $team = $viewData->offsetGet('team'); - if ($team) { - $this->playerIds = array_flip(\Tx_Rnbase_Utility_Strings::intExplode(',', $team->getProperty('players'))); + $listBuilder = tx_rnbase::makeInstance(ListBuilder::class); + if ($viewData->offsetExists('team')) { + $team = $viewData->offsetGet('team'); + $this->playerIds = array_flip(Strings::intExplode(',', $team->getProperty('players'))); $listBuilder->addVisitor([ $this, 'highlightPlayer', @@ -60,7 +64,7 @@ protected function createOutput($template, RequestInterface $request, $formatter $markerClass = PlayerStatsMarker::class; } - $subTemplate = \tx_rnbase_util_Templates::getSubpart($template, '###'.strtoupper($type).'###'); + $subTemplate = Templates::getSubpart($template, '###'.strtoupper($type).'###'); $out .= $listBuilder->render($data, $viewData, $subTemplate, $markerClass, $request ->getConfId().$type.'.data.', 'DATA', $formatter); } diff --git a/Classes/View/RefereeStats.php b/Classes/View/RefereeStats.php index 96318d0..00d6f69 100644 --- a/Classes/View/RefereeStats.php +++ b/Classes/View/RefereeStats.php @@ -2,15 +2,18 @@ namespace System25\T3sports\View; +use Sys25\RnBase\Frontend\Marker\ListBuilder; +use Sys25\RnBase\Frontend\Marker\Templates; use Sys25\RnBase\Frontend\Request\RequestInterface; use Sys25\RnBase\Frontend\View\ContextInterface; use Sys25\RnBase\Frontend\View\Marker\BaseView; use System25\T3sports\Marker\RefereeStatsMarker; +use tx_rnbase; /*************************************************************** * Copyright notice * - * (c) 2010-2020 Rene Nitzsche (rene@system25.de) + * (c) 2010-2023 Rene Nitzsche (rene@system25.de) * All rights reserved * * This script is part of the TYPO3 project. The TYPO3 project is @@ -40,11 +43,11 @@ protected function createOutput($template, RequestInterface $request, $formatter $viewData = $request->getViewContext(); $items = &$viewData->offsetGet('items'); - $listBuilder = \tx_rnbase::makeInstance('tx_rnbase_util_ListBuilder'); + $listBuilder = tx_rnbase::makeInstance(ListBuilder::class); $out = ''; foreach ($items as $type => $data) { - $subTemplate = \tx_rnbase_util_Templates::getSubpart($template, '###'.strtoupper($type).'###'); + $subTemplate = Templates::getSubpart($template, '###'.strtoupper($type).'###'); $out .= $listBuilder->render($data, $viewData, $subTemplate, RefereeStatsMarker::class, $request ->getConfId().$type.'.data.', 'DATA', $formatter); } diff --git a/Configuration/PageTS/modWizards.ts b/Configuration/PageTS/modWizards.tsconfig similarity index 100% rename from Configuration/PageTS/modWizards.ts rename to Configuration/PageTS/modWizards.tsconfig diff --git a/Configuration/PageTS/moduleConfig.tss b/Configuration/PageTS/moduleConfig.tsconfig similarity index 100% rename from Configuration/PageTS/moduleConfig.tss rename to Configuration/PageTS/moduleConfig.tsconfig diff --git a/Configuration/Services.php b/Configuration/Services.php new file mode 100644 index 0000000..b59c28a --- /dev/null +++ b/Configuration/Services.php @@ -0,0 +1,12 @@ +registerForAutoconfiguration(StatsInterface::class)->addTag('t3sports.stats.indexer'); + $containerBuilder->addCompilerPass(new DependencyInjection\StatsIndexerPass()); +}; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 0000000..bd70950 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,13 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + System25\T3sports\: + resource: '../Classes/*' + exclude: ['../Classes/Domain/Model/*'] + + # public, damit das Autowiring beim Hook-Aufruf klappt. Gibt es ein Tag für Hooks? + System25\T3sports\Hooks\ClearStats: + public: true diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index 821500d..f2f696c 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -1,6 +1,8 @@ [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg)](https://php.net/) [![Latest Stable Version](https://img.shields.io/packagist/v/digedag/t3sportstats.svg?maxAge=3600)](https://packagist.org/packages/digedag/t3sportstats) @@ -11,6 +11,7 @@ Follow @T3sports1 +[CHANGELOG](ChangeLog.md) What is this extension for? diff --git a/composer.json b/composer.json index 5b91e38..72b1fd6 100644 --- a/composer.json +++ b/composer.json @@ -24,10 +24,10 @@ "typo3-ter/t3sportstats" : "self.version" }, "require" : { - "typo3/cms-core" : "^8.7 || ^9.5.17 || ^10.4.3 || ^11.5.3", - "digedag/rn-base" : "^1.16.0", - "digedag/cfc-league" : "^1.10.0", - "digedag/cfc-league-fe" : "^1.10.0" + "typo3/cms-core": "^8.7 || ^9.5 || ^10.4 || ^11.5 || ^12.1", + "digedag/rn-base": "^1.16.0", + "digedag/cfc-league": "^1.10.0", + "digedag/cfc-league-fe": "^1.10.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.1.0", diff --git a/ext_emconf.php b/ext_emconf.php index ebc492f..79e5798 100755 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -17,7 +17,7 @@ 'author' => 'Rene Nitzsche', 'author_email' => 'rene@system25.de', 'author_company' => 'System 25', - 'version' => '1.4.0', + 'version' => '1.5.0', 'dependencies' => '', 'module' => '', 'state' => 'stable', @@ -26,10 +26,10 @@ 'clearCacheOnLoad' => 1, 'constraints' => [ 'depends' => [ - 'typo3' => '8.7.0-11.5.99', - 'rn_base' => '1.16.0-0.0.0', - 'cfc_league' => '1.10.0-0.0.0', - 'cfc_league_fe' => '1.10.0-0.0.0', + 'typo3' => '8.7.0-12.4.99', + 'rn_base' => '1.17.0-0.0.0', + 'cfc_league' => '1.11.0-0.0.0', + 'cfc_league_fe' => '1.11.0-0.0.0', ], 'conflicts' => [], 'suggests' => [], diff --git a/ext_localconf.php b/ext_localconf.php index 19af829..b61610e 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,6 +1,6 @@ handleMatchFilter'; -Sys25\RnBase\Utility\Extensions::addService( - $_EXTKEY, - 't3sportstats' /* sv type */ , - 'tx_t3sportstats_srv_Statistics' /* sv key */ , - [ - 'title' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db:service_t3sports_statistics_title', 'description' => 'Statistical data about T3sports', 'subtype' => 'statistics', - 'available' => true, 'priority' => 50, 'quality' => 50, - 'os' => '', 'exec' => '', - 'className' => System25\T3sports\Service\Statistics::class, - ] -); - -Sys25\RnBase\Utility\Extensions::addService( - $_EXTKEY, - 't3sportsPlayerStats' /* sv type */ , - 'PlayerStats' /* sv key */ , - [ - 'title' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db:service_t3sports_playerstats_title', 'description' => 'Statistical data about players', 'subtype' => 'base', - 'available' => true, 'priority' => 50, 'quality' => 50, - 'os' => '', 'exec' => '', - 'className' => System25\T3sports\StatsIndexer\PlayerStats::class, - ] -); - -Sys25\RnBase\Utility\Extensions::addService( - $_EXTKEY, - 't3sportsPlayerStats' /* sv type */ , - 'PlayerTimeStats' /* sv key */ , - [ - 'title' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db:service_t3sports_playertimestats_title', 'description' => 'Statistical data about players', 'subtype' => 'playtime', - 'available' => true, 'priority' => 50, 'quality' => 50, - 'os' => '', 'exec' => '', - 'className' => System25\T3sports\StatsIndexer\PlayerTimeStats::class, - ] -); - -Sys25\RnBase\Utility\Extensions::addService( - $_EXTKEY, - 't3sportsPlayerStats' /* sv type */ , - 'PlayerGoalStats' /* sv key */ , - [ - 'title' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db:service_t3sports_playertimestats_title', 'description' => 'Statistical data about players', 'subtype' => 'goals', - 'available' => true, 'priority' => 50, 'quality' => 50, - 'os' => '', 'exec' => '', - 'className' => System25\T3sports\StatsIndexer\PlayerGoalStats::class, - ] -); - -Sys25\RnBase\Utility\Extensions::addService( - $_EXTKEY, - 't3sportsCoachStats' /* sv type */ , - 'CoachStats' /* sv key */ , - [ - 'title' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db:service_t3sports_playerstats_title', 'description' => 'Statistical data about coaches', 'subtype' => 'base', - 'available' => true, 'priority' => 50, 'quality' => 50, - 'os' => '', 'exec' => '', - 'className' => System25\T3sports\StatsIndexer\CoachStats::class, - ] -); - -Sys25\RnBase\Utility\Extensions::addService( - $_EXTKEY, - 't3sportsRefereeStats' /* sv type */ , - 'RefereeStats' /* sv key */ , - [ - 'title' => 'LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db:service_t3sports_playerstats_title', 'description' => 'Statistical data about referees', 'subtype' => 'base', - 'available' => true, 'priority' => 50, 'quality' => 50, - 'os' => '', 'exec' => '', - 'className' => System25\T3sports\StatsIndexer\RefereeStats::class, - ] -); +if (!\Sys25\RnBase\Utility\TYPO3::isTYPO104OrHigher()) { + $provider = \System25\T3sports\Service\StatsIndexerProvider::getInstance(); + $provider->addStatsIndexer(new \System25\T3sports\StatsIndexer\CoachStats()); + $provider->addStatsIndexer(new \System25\T3sports\StatsIndexer\PlayerStats()); + $provider->addStatsIndexer(new \System25\T3sports\StatsIndexer\PlayerGoalStats()); + $provider->addStatsIndexer(new \System25\T3sports\StatsIndexer\PlayerTimeStats()); + $provider->addStatsIndexer(new \System25\T3sports\StatsIndexer\RefereeStats()); +} System25\T3sports\Utility\StatsConfig::registerPlayerStatsSimple('goals', '10,11,12,13'); System25\T3sports\Utility\StatsConfig::registerPlayerStatsSimple('assists', '31'); @@ -126,3 +63,12 @@ // Register a new matchnote type System25\T3sports\Utility\Misc::registerMatchNote('LLL:EXT:t3sportstats/Resources/Private/Language/locallang_db:tx_cfcleague_match_notes.type.goalfreekick', '13'); + +if (\Sys25\RnBase\Utility\Environment::isBackend()) { + // Einbindung einer PageTSConfig + // since T3 12 pagets is loaded by convention + if (!\Sys25\RnBase\Utility\TYPO3::isTYPO121OrHigher()) { + \Sys25\RnBase\Utility\Extensions::addPageTSConfig(''); + \Sys25\RnBase\Utility\Extensions::addPageTSConfig(''); + } +} diff --git a/ext_tables.php b/ext_tables.php index f5370cb..647a7a6 100755 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,14 +1,10 @@ '); - \Sys25\RnBase\Utility\Extensions::addPageTSConfig(''); - +if (\Sys25\RnBase\Utility\Environment::isBackend()) { //////////////////////////////// // Submodul anmelden ////////////////////////////////