Skip to content

Commit

Permalink
#99 Add judo as sports
Browse files Browse the repository at this point in the history
  • Loading branch information
digedag committed Mar 10, 2024
1 parent fe2bb20 commit 212e894
Show file tree
Hide file tree
Showing 18 changed files with 353 additions and 53 deletions.
14 changes: 8 additions & 6 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 @@ -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->hasPoints()) {
$arr[] = $LANG->getLL('tx_cfcleague_games_points_home');
$arr[] = $LANG->getLL('tx_cfcleague_games_points_guest');
}

$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->hasPoints()) {
$row[] = $this->formTool->createTxtInput('data[tx_cfcleague_games]['.$matchUid.'][points_home]', $match->getProperty('points_home'), 12);
$row[] = $this->formTool->createTxtInput('data[tx_cfcleague_games]['.$matchUid.'][points_guest]', $match->getProperty('points_guest'), 12);
}

$row[] = $this->formTool->createIntInput('data[tx_cfcleague_games]['.$matchUid.'][visitors]', $match->getProperty('visitors'), 6);
$arr[0][] = $row;
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)]);
}
}
}
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
17 changes: 13 additions & 4 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 hasPoints(): bool
{
return false;
}
Expand All @@ -69,4 +73,9 @@ public function getMatchInfo()

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 hasPoints(): bool
{
return false;
}
Expand All @@ -72,4 +76,9 @@ public function getMatchInfo()

return $this->matchInfo;
}

public function getIdentifier(): string
{
return 'handball';
}
}
6 changes: 5 additions & 1 deletion Classes/Sports/ISports.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,14 @@ public function getTCALabel();
/**
* @return bool
*/
public function isSetBased();
public function isSetBased(): bool;

public function hasPoints(): bool;

/**
* @return MatchInfo
*/
public function getMatchInfo();

public function getIdentifier(): string;
}
17 changes: 13 additions & 4 deletions Classes/Sports/IceHockey.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-2020 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 IceHockey extends AbstractService implements ISports
class IceHockey implements ISports
{
/**
* @return array
Expand All @@ -47,7 +46,12 @@ public function getTCALabel()
return 'Icehockey';
}

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

public function hasPoints(): bool
{
return false;
}
Expand All @@ -70,4 +74,9 @@ public function getMatchInfo()

return $this->matchInfo;
}

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

0 comments on commit 212e894

Please sign in to comment.