Skip to content

Commit

Permalink
#35 show current series
Browse files Browse the repository at this point in the history
  • Loading branch information
digedag committed Oct 11, 2024
1 parent 32d0fa8 commit 2f58d64
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
35 changes: 33 additions & 2 deletions Classes/Frontend/Marker/SeriesResultMarker.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Sys25\RnBase\Frontend\Marker\FormatUtil;
use Sys25\RnBase\Frontend\Marker\SimpleMarker;
use System25\T3sports\Model\Fixture;
use System25\T3sports\Model\Series;
use System25\T3sports\Model\SeriesResult;
use tx_rnbase;

Expand Down Expand Up @@ -40,12 +41,14 @@
class SeriesResultMarker extends SimpleMarker
{
private $fixtureRepo;
private $seriesRepo;

public function __construct($options = [])
{
$this->setClassname(SeriesResult::class);
parent::__construct($options);
$this->fixtureRepo = RepositoryRegistry::getRepositoryForClass(Fixture::class);
$this->seriesRepo = RepositoryRegistry::getRepositoryForClass(Series::class);
}

/**
Expand All @@ -65,12 +68,15 @@ protected function prepareTemplate($template, $item, $formatter, $confId, $marke
if (self::containsMarker($template, $marker.'_LASTMATCH_')) {
$template = $this->addFixture($template, $item->getProperty('lastmatch'), $formatter, $confId.'lastmatch.', $marker.'_LASTMATCH');
}
if (self::containsMarker($template, $marker.'_SERIES_')) {
$template = $this->addSeries($template, $item->getProperty('parentid'), $formatter, $confId.'series.', $marker.'_SERIES');
}

return $template;
}

/**
* Bindet den Spieler ein.
* Bindet ein Spiel ein.
*
* @param string $template
* @param int $fixtureUid
Expand All @@ -80,7 +86,7 @@ protected function prepareTemplate($template, $item, $formatter, $confId, $marke
*
* @return string
*/
private function addFixture($template, $fixtureUid, $formatter, $confId, $markerPrefix)
private function addFixture($template, $fixtureUid, FormatUtil $formatter, $confId, $markerPrefix)
{
if (!$fixtureUid) {
// Kein Item vorhanden. Leere Instanz anlegen und altname setzen
Expand All @@ -93,4 +99,29 @@ private function addFixture($template, $fixtureUid, $formatter, $confId, $marker

return $template;
}

/**
* Bindet die Serie ein.
*
* @param string $template
* @param int $fixtureUid
* @param FormatUtil $formatter
* @param string $confId
* @param string $markerPrefix
*
* @return string
*/
private function addSeries($template, $fixtureUid, FormatUtil $formatter, $confId, $markerPrefix)
{
if (!$fixtureUid) {
// Kein Item vorhanden. Leere Instanz anlegen und altname setzen
$sub = BaseMarker::getEmptyInstance(Series::class);
} else {
$sub = $this->seriesRepo->findByUid($fixtureUid);
}
$marker = tx_rnbase::makeInstance(SeriesMarker::class);
$template = $marker->parseTemplate($template, $sub, $formatter, $confId, $markerPrefix);

return $template;
}
}
5 changes: 5 additions & 0 deletions Resources/Private/Templates/seriesresultlist.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<h2>Die aktuellen Serien</h2>

###RESULTS###
<div class="alert alert-warning">
<table class="table table-striped table-bordered">
<thead class="table-dark">
<tr>
Expand All @@ -21,6 +22,9 @@ <h2>Die aktuellen Serien</h2>
</thead>
<tbody>
###RESULT###
<tr>
<td colspan="3">Name: ###RESULT_SERIES_LABEL###</td>
</tr>
<tr>
<td>###RESULT_FIXTURESLINK### ###RESULT_QUANTITY######RESULT_FIXTURESLINK###</td>
<td>###RESULT_FIRSTMATCH_DATE###<br>
Expand All @@ -39,6 +43,7 @@ <h2>Die aktuellen Serien</h2>
###RESULT###
</tbody>
</table>
</div>
###RESULTEMPTYLIST###
<span class="badge badge-warning">###LABEL_NO_RESULTS_FOUND###</span>
###RESULTEMPTYLIST###
Expand Down

0 comments on commit 2f58d64

Please sign in to comment.