Skip to content

Commit

Permalink
Feature/judo (#100)
Browse files Browse the repository at this point in the history
* #99 Add judo as sports
* register types of sports as symfony service
  • Loading branch information
digedag committed Mar 29, 2024
1 parent fe2bb20 commit 1fcffca
Show file tree
Hide file tree
Showing 29 changed files with 413 additions and 143 deletions.
24 changes: 13 additions & 11 deletions Classes/Controller/Competition.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Sys25\RnBase\Backend\Form\ToolBox;
use Sys25\RnBase\Backend\Module\BaseModFunc;
use Sys25\RnBase\Configuration\ConfigurationInterface;
use Sys25\RnBase\Frontend\Marker\FormatUtil;
use Sys25\RnBase\Frontend\Marker\Templates;
use System25\T3sports\Controller\Competition\DfbSync;
Expand All @@ -17,7 +16,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2008-2023 Rene Nitzsche ([email protected])
* (c) 2008-2024 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand Down Expand Up @@ -53,6 +52,10 @@ class Competition extends BaseModFunc
* @var DfbSync
*/
private $dfbSync;
/**
* @var MatchEdit
*/
private $matchEdit;

public $MCONF;

Expand All @@ -71,9 +74,10 @@ public function getModuleIdentifier()
return 'cfc_league';
}

public function __construct(?DfbSync $dfbSync = null)
public function __construct(?MatchEdit $matchEdit = null, ?DfbSync $dfbSync = null)
{
$this->dfbSync = $dfbSync ?: tx_rnbase::makeInstance(DfbSync::class);
$this->matchEdit = $matchEdit ?: tx_rnbase::makeInstance(MatchEdit::class);
}

/**
Expand Down Expand Up @@ -119,11 +123,11 @@ protected function getContent($template, &$configurations, &$formatter, $formToo

$menu = $this->selector->showTabMenu($this->getModule()
->getPid(), 'comptools', [
'0' => $lang->getLL('edit_games'),
'1' => $lang->getLL('mod_compteams'),
'2' => $lang->getLL('create_games'),
'3' => $lang->getLL('mod_compdfbsync'),
]);
'0' => $lang->getLL('edit_games'),
'1' => $lang->getLL('mod_compteams'),
'2' => $lang->getLL('create_games'),
'3' => $lang->getLL('mod_compdfbsync'),
]);

$tabs = $menu['menu'];
$tabs .= '<div style="display: block; border: 1px solid #a2aab8;" ></div>';
Expand Down Expand Up @@ -168,9 +172,7 @@ protected function getContent($template, &$configurations, &$formatter, $formToo

private function showEditMatches($current_league, $module)
{
/** @var MatchEdit $subMod */
$subMod = tx_rnbase::makeInstance(MatchEdit::class);
$content = $subMod->main($module, $current_league);
$content = $this->matchEdit->main($module, $current_league);

return $content;
}
Expand Down
18 changes: 13 additions & 5 deletions Classes/Controller/Competition/MatchEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2007-2023 Rene Nitzsche ([email protected])
* (c) 2007-2024 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand Down Expand Up @@ -65,9 +65,9 @@ class MatchEdit
*/
private $module;

public function __construct()
public function __construct(?ServiceLocator $serviceLocator = null)
{
$this->sportsServiceLocator = new ServiceLocator();
$this->sportsServiceLocator = $serviceLocator ?? ServiceLocator::getInstance();
}

/**
Expand Down Expand Up @@ -277,10 +277,14 @@ private function getHeadline($parts, $competition)
$arr[] = $label ? $label : $i.'. part';
}
}
$sports = $this->sportsServiceLocator->getSportsService($competition->getSports());
$sports = $this->sportsServiceLocator->getSportsByIdentifier($competition->getSports());
if ($sports->isSetBased()) {
$arr[] = $LANG->getLL('tx_cfcleague_games_sets');
}
if ($sports->hasScore()) {
$arr[] = $LANG->getLL(sprintf('tx_cfcleague_games_%s_score_home', $sports->getIdentifier()));
$arr[] = $LANG->getLL(sprintf('tx_cfcleague_games_%s_score_guest', $sports->getIdentifier()));
}

$arr[] = $LANG->getLL('tx_cfcleague_games.visitors');

Expand Down Expand Up @@ -349,10 +353,14 @@ private function createTableArray($matches, $competition)
$row[] = $this->formTool->createIntInput('data[tx_cfcleague_games]['.$matchUid.'][goals_home_'.$i.']', $match->getProperty('goals_home_'.$i), 3).' : '.$this->formTool->createIntInput('data[tx_cfcleague_games]['.$matchUid.'][goals_guest_'.$i.']', $match->getProperty('goals_guest_'.$i), 3);
}

$sports = $this->sportsServiceLocator->getSportsService($competition->getSports());
$sports = $this->sportsServiceLocator->getSportsByIdentifier($competition->getSports());
if ($sports->isSetBased()) {
$row[] = $this->formTool->createTxtInput('data[tx_cfcleague_games]['.$matchUid.'][sets]', $match->getProperty('sets'), 12);
}
if ($sports->hasScore()) {
$row[] = $this->formTool->createTxtInput('data[tx_cfcleague_games]['.$matchUid.'][score_home]', $match->getProperty('score_home'), 6);
$row[] = $this->formTool->createTxtInput('data[tx_cfcleague_games]['.$matchUid.'][score_guest]', $match->getProperty('score_guest'), 6);
}

$row[] = $this->formTool->createIntInput('data[tx_cfcleague_games]['.$matchUid.'][visitors]', $match->getProperty('visitors'), 6);
$arr[0][] = $row;
Expand Down
6 changes: 3 additions & 3 deletions Classes/Controller/Competition/MatchTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ private function showMatchTable(Competition $comp)
$menu = $this->getFormTool()->showMenu($this->getModule()
->getPid(), 't3s_mcmode', $this->getModule()
->getName(), [
0 => 'Auto',
'1' => 'Manual',
]);
0 => 'Auto',
'1' => 'Manual',
]);
$content .= $menu['menu'];
$mode = $menu['value'];
$content .= '<br>';
Expand Down
16 changes: 8 additions & 8 deletions Classes/Controller/MatchTicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,27 +540,27 @@ protected function createFormArray(Fixture $match)
$row[] = $this->getModule()
->getFormTool()
->createSelectByArray('data[tx_cfcleague_match_notes][NEW'.$i.'][type]', '0', $types, [
ToolBox::OPTION_CSS_CLASSES => 'tickerField',
]);
ToolBox::OPTION_CSS_CLASSES => 'tickerField',
]);
$row[] = $this->getModule()
->getFormTool()
->createSelectByArray('data[tx_cfcleague_match_notes][NEW'.$i.'][player_home]', '0', $playersHome, [
ToolBox::OPTION_CSS_CLASSES => 'tickerField',
]);
ToolBox::OPTION_CSS_CLASSES => 'tickerField',
]);
$row[] = $this->getModule()
->getFormTool()
->createSelectByArray('data[tx_cfcleague_match_notes][NEW'.$i.'][player_guest]', '0', $playersGuest, [
ToolBox::OPTION_CSS_CLASSES => 'tickerField',
]);
ToolBox::OPTION_CSS_CLASSES => 'tickerField',
]);
$arr[] = $row;

// Das Bemerkungsfeld kommt in die nächste Zeile
$row = [];
$row[] = $this->getModule()
->getFormTool()
->createTextArea('data[tx_cfcleague_match_notes][NEW'.$i.'][comment]', '', $cols, $rows, [
ToolBox::OPTION_CSS_CLASSES => 'tickerField',
]);
ToolBox::OPTION_CSS_CLASSES => 'tickerField',
]);
$arr[] = $row;
}

Expand Down
8 changes: 4 additions & 4 deletions Classes/Controller/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ protected function getContent($template, &$configurations, &$formatter, $formToo
// Wenn ein Team gefunden ist, dann können wir das Modul schreiben
$menu = $this->selector->showTabMenu($this->getModule()
->getPid(), 'teamtools', [
'0' => $LANG->getLL('create_players'),
'1' => $LANG->getLL('add_players'),
'2' => $LANG->getLL('manage_teamnotes'),
]);
'0' => $LANG->getLL('create_players'),
'1' => $LANG->getLL('add_players'),
'2' => $LANG->getLL('manage_teamnotes'),
]);

$tabs = $menu['menu'];
$tabs .= '<div style="display: block; border: 1px solid #a2aab8;" ></div>';
Expand Down
29 changes: 29 additions & 0 deletions Classes/DependencyInjection/SportsCompilerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace System25\T3sports\DependencyInjection;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use System25\T3sports\Sports\ServiceLocator;

class SportsCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
// always first check if the primary service is defined
if (!$container->has(ServiceLocator::class)) {
return;
}

$definition = $container->findDefinition(ServiceLocator::class);

// find all service IDs with the t3sports.sports tag
$taggedServices = $container->findTaggedServiceIds('t3sports.sports');

foreach ($taggedServices as $id => $tags) {
// add the indexer to the IndexerProvider service
$definition->addMethodCall('addSports', [new Reference($id)]);
}
}
}
12 changes: 11 additions & 1 deletion Classes/Model/Fixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/***************************************************************
* Copyright notice
*
* (c) 2007-2023 Rene Nitzsche ([email protected])
* (c) 2007-2027 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand Down Expand Up @@ -91,6 +91,16 @@ public function getGoalsGuest($matchPart = '')
return $ret;
}

public function getScoreHome(): int
{
return (int) $this->getProperty('score_home');
}

public function getScoreGuest(): int
{
return (int) $this->getProperty('score_guest');
}

/**
* Liefert den TOTO-Wert des Spiels.
* Als 0 für ein Unentschieden, 1 für einen Heim-
Expand Down
15 changes: 9 additions & 6 deletions Classes/Service/CompetitionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use System25\T3sports\Model\Competition;
use System25\T3sports\Model\Repository\CompetitionRepository;
use System25\T3sports\Model\Saison;
use System25\T3sports\Sports\ServiceLocator;
use System25\T3sports\Utility\ServiceRegistry;

/***************************************************************
Expand Down Expand Up @@ -45,10 +46,12 @@ class CompetitionService extends AbstractService
* @var CompetitionRepository
*/
private $repo;
private $sportsServiceLocator;

public function __construct(?CompetitionRepository $repo = null)
public function __construct(?ServiceLocator $serviceLocator = null, ?CompetitionRepository $repo = null)
{
$this->repo = $repo ?: new CompetitionRepository();
$this->sportsServiceLocator = $serviceLocator ?? ServiceLocator::getInstance();
}

/**
Expand Down Expand Up @@ -120,9 +123,9 @@ public function search($fields, $options)

public function getPointSystems($sports)
{
$srv = \System25\T3sports\Utility\Misc::getSports($sports);
$sports = $this->sportsServiceLocator->getSportsByIdentifier($sports);

return $srv->getTCAPointSystems();
return $sports->getTCAPointSystems();
}

/**
Expand All @@ -135,11 +138,11 @@ public function getSports4TCA()
$items = [];

// Jetzt schauen, ob noch weitere Sportarten per Service geliefert werden
$sportsData = \System25\T3sports\Utility\Misc::lookupSports();
$sportsData = $this->sportsServiceLocator->getAllSports();
foreach ($sportsData as $data) {
$items[] = [
Misc::translateLLL($data['sports']->getTCALabel()),
$data['type'],
Misc::translateLLL($data->getTCALabel()),
$data->getIdentifier(),
];
}

Expand Down
23 changes: 16 additions & 7 deletions Classes/Sports/Football.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace System25\T3sports\Sports;

use Sys25\RnBase\Typo3Wrapper\Service\AbstractService;
use Sys25\RnBase\Utility\Misc;
use tx_rnbase;

/***************************************************************
* Copyright notice
*
* (c) 2008-2021 Rene Nitzsche ([email protected])
* (c) 2008-2024 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand All @@ -29,7 +28,7 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

class Football extends AbstractService implements ISports
class Football implements ISports
{
/**
* @return array
Expand All @@ -47,7 +46,12 @@ public function getTCALabel()
return 'Football';
}

public function isSetBased()
public function isSetBased(): bool
{
return false;
}

public function hasScore(): bool
{
return false;
}
Expand All @@ -61,12 +65,17 @@ public function getMatchInfo()
{
if (null == $this->matchInfo) {
$this->matchInfo = tx_rnbase::makeInstance(MatchInfo::class, [
MatchInfo::MATCH_TIME => 90,
MatchInfo::MATCH_PARTS => 2,
MatchInfo::MATCH_EXTRA_TIME => 30,
MatchInfo::MATCH_TIME => 90,
MatchInfo::MATCH_PARTS => 2,
MatchInfo::MATCH_EXTRA_TIME => 30,
]);
}

return $this->matchInfo;
}

public function getIdentifier(): string
{
return 'football';
}
}
17 changes: 13 additions & 4 deletions Classes/Sports/Handball.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

namespace System25\T3sports\Sports;

use Sys25\RnBase\Typo3Wrapper\Service\AbstractService;
use Sys25\RnBase\Utility\Misc;
use tx_rnbase;

/***************************************************************
* Copyright notice
*
* (c) 2017-2020 Rene Nitzsche ([email protected])
* (c) 2017-2024 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand All @@ -29,7 +28,7 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

class Handball extends AbstractService implements ISports
class Handball implements ISports
{
/**
* @return array
Expand All @@ -49,7 +48,12 @@ public function getTCALabel()
return 'Handball';
}

public function isSetBased()
public function isSetBased(): bool
{
return false;
}

public function hasScore(): bool
{
return false;
}
Expand All @@ -72,4 +76,9 @@ public function getMatchInfo()

return $this->matchInfo;
}

public function getIdentifier(): string
{
return 'handball';
}
}
Loading

0 comments on commit 1fcffca

Please sign in to comment.