Skip to content

Commit

Permalink
Update filter classes
Browse files Browse the repository at this point in the history
  • Loading branch information
digedag committed May 29, 2022
1 parent 23394c2 commit a131954
Show file tree
Hide file tree
Showing 10 changed files with 115 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/.Build
/composer.lock
/var
.php_cs.cache
.php-cs-fixer.cache

### eclipse files
.settings
Expand Down
5 changes: 3 additions & 2 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setFinder($finder)
$config = new PhpCsFixer\Config();
return $config->setFinder($finder)
->setRules([
'@Symfony' => true,
'phpdoc_align' => false,
'no_superfluous_phpdoc_tags' => false,
'single_line_comment_spacing' => false,
])
->setLineEnding("\n")
;
21 changes: 12 additions & 9 deletions Classes/Action/CoachStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

namespace System25\T3sports\Action;

use Sys25\RnBase\Configuration\ConfigurationInterface;
use Sys25\RnBase\Frontend\Controller\AbstractAction;
use Sys25\RnBase\Frontend\Filter\BaseFilter;
use Sys25\RnBase\Frontend\Request\RequestInterface;
use Sys25\RnBase\Utility\Strings;
use System25\T3sports\Model\Team;
use System25\T3sports\Service\StatsServiceRegistry;

/***************************************************************
Expand Down Expand Up @@ -41,25 +45,24 @@ class CoachStats extends AbstractAction
*/
protected function handleRequest(RequestInterface $request)
{
$parameters = $request->getParameters();
$configurations = $request->getConfigurations();
$viewData = $request->getViewContext();

// Zuerst die Art der Statistik ermitteln
$types = \Tx_Rnbase_Utility_Strings::trimExplode(',', $configurations->get($this->getConfId().'statisticTypes'), 1);
$types = Strings::trimExplode(',', $configurations->get($this->getConfId().'statisticTypes'), 1);
if (!count($types)) {
// Abbruch kein Typ angegeben
throw new \Exception('No statistics type configured in: '.$this->getConfId().'statisticTypes');
}

$statsData = [];
foreach ($types as $type) {
$statsData[$type] = $this->findData($parameters, $configurations, $viewData, $type);
$statsData[$type] = $this->findData($request, $viewData, $type);
}
$viewData->offsetSet('items', $statsData);
$teamId = $configurations->get($this->getConfId().'highlightTeam');
if ($teamId) {
$team = \tx_cfcleague_models_Team::getInstance($teamId);
$team = Team::getInstance($teamId);
if (is_object($team) && $team->isValid()) {
$viewData->offsetSet('team', $team);
}
Expand All @@ -68,23 +71,23 @@ protected function handleRequest(RequestInterface $request)
return null;
}

private function findData($parameters, $configurations, $viewData, $type)
private function findData(RequestInterface $request, $viewData, $type)
{
$srv = (new StatsServiceRegistry())->getStatisticService();
$confId = $this->getConfId().$type.'.';
$filter = \tx_rnbase_filter_BaseFilter::createFilter($parameters, $configurations, $viewData, $confId);
$filter = BaseFilter::createFilter($request, $confId);

$fields = [];
$options = [
'enablefieldsoff' => 1,
];
$filter->init($fields, $options);
$debug = $configurations->get($this->getConfId().'options.debug');
$debug = $request->getConfigurations()->get($this->getConfId().'options.debug');
if ($debug) {
$options['debug'] = 1;
}

self::handlePageBrowser($configurations, $confId.'data.pagebrowser', $viewData, $fields, $options, [
self::handlePageBrowser($request->getConfigurations(), $confId.'data.pagebrowser', $viewData, $fields, $options, [
'searchcallback' => [
$srv,
'searchCoachStats',
Expand All @@ -108,7 +111,7 @@ private function findData($parameters, $configurations, $viewData, $type)
* @param array $fields
* @param array $options
*/
private static function handlePageBrowser($configurations, $confid, &$viewdata, &$fields, &$options, $cfg = [])
private static function handlePageBrowser(ConfigurationInterface $configurations, $confid, &$viewdata, &$fields, &$options, $cfg = [])
{
$confid .= '.';
if (is_array($configurations->get($confid))) {
Expand Down
8 changes: 5 additions & 3 deletions Classes/Action/DBStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace System25\T3sports\Action;

use Sys25\RnBase\Database\Connection;
use Sys25\RnBase\Frontend\Controller\AbstractAction;
use Sys25\RnBase\Frontend\Request\RequestInterface;
use Sys25\RnBase\Utility\Strings;

/***************************************************************
* Copyright notice
*
* (c) 2010-2017 Rene Nitzsche ([email protected])
* (c) 2010-2022 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand Down Expand Up @@ -45,7 +47,7 @@ protected function handleRequest(RequestInterface $request)
$viewData = $request->getViewContext();

// Zuerst die Art der Statistik ermitteln
$tables = \Tx_Rnbase_Utility_Strings::trimExplode(',', $configurations->get($this->getConfId().'tables'), 1);
$tables = Strings::trimExplode(',', $configurations->get($this->getConfId().'tables'), 1);
if (!count($tables)) {
// Abbruch kein Typ angegeben
throw new \Exception('No database table configured in: '.$this->getConfId().'tables');
Expand All @@ -69,7 +71,7 @@ private function findData($parameters, $configurations, $viewData, $table)
$options['debug'] = 1;
}

$res = \Tx_Rnbase_Database_Connection::getInstance()->doSelect('count(*) AS cnt', $table, $options);
$res = Connection::getInstance()->doSelect('count(*) AS cnt', $table, $options);

$items['size'] = $res[0]['cnt'];

Expand Down
30 changes: 18 additions & 12 deletions Classes/Action/PlayerStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

namespace System25\T3sports\Action;

use Sys25\RnBase\Configuration\ConfigurationInterface;
use Sys25\RnBase\Frontend\Controller\AbstractAction;
use Sys25\RnBase\Frontend\Filter\BaseFilter;
use Sys25\RnBase\Frontend\Request\RequestInterface;
use Sys25\RnBase\Utility\Misc;
use Sys25\RnBase\Utility\PageBrowser;
use Sys25\RnBase\Utility\Strings;
use System25\T3sports\Service\StatsServiceRegistry;
use tx_rnbase;

/***************************************************************
* Copyright notice
*
* (c) 2010-2018 Rene Nitzsche ([email protected])
* (c) 2010-2022 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand Down Expand Up @@ -38,20 +44,19 @@ class PlayerStats extends AbstractAction
*/
protected function handleRequest(RequestInterface $request)
{
$parameters = $request->getParameters();
$configurations = $request->getConfigurations();
$viewData = $request->getViewContext();

// Zuerst die Art der Statistik ermitteln
$types = \Tx_Rnbase_Utility_Strings::trimExplode(',', $configurations->get($this->getConfId().'statisticTypes'), 1);
$types = Strings::trimExplode(',', $configurations->get($this->getConfId().'statisticTypes'), 1);
if (!count($types)) {
// Abbruch kein Typ angegeben
throw new \Exception('No statistics type configured in: '.$this->getConfId().'statisticTypes');
}

$statsData = [];
foreach ($types as $type) {
$statsData[$type] = $this->findData($parameters, $configurations, $viewData, $type);
$statsData[$type] = $this->findData($request, $viewData, $type);
}
$viewData->offsetSet('items', $statsData);
$teamId = $configurations->get($this->getConfId().'highlightTeam');
Expand All @@ -65,23 +70,23 @@ protected function handleRequest(RequestInterface $request)
return null;
}

private function findData($parameters, $configurations, $viewData, $type)
private function findData(RequestInterface $request, $viewData, $type)
{
$srv = (new StatsServiceRegistry())->getStatisticService();
$confId = $this->getConfId().$type.'.';
$filter = \tx_rnbase_filter_BaseFilter::createFilter($parameters, $configurations, $viewData, $confId);
$filter = BaseFilter::createFilter($request, $confId);

$fields = [];
$options = [
'enablefieldsoff' => 1,
];
$filter->init($fields, $options);
$debug = $configurations->get($this->getConfId().'options.debug');
$debug = $request->getConfigurations()->get($this->getConfId().'options.debug');
if ($debug) {
$options['debug'] = 1;
}

self::handlePageBrowser($configurations, $confId.'data.pagebrowser', $viewData, $fields, $options, [
self::handlePageBrowser($request->getConfigurations(), $confId.'data.pagebrowser', $viewData, $fields, $options, [
'searchcallback' => [
$srv,
'searchPlayerStats',
Expand All @@ -90,13 +95,13 @@ private function findData($parameters, $configurations, $viewData, $type)
]);

$items = $srv->searchPlayerStats($fields, $options);
\tx_rnbase_util_Misc::callHook('t3sportstats', 'playerstats_finddata', [
Misc::callHook('t3sportstats', 'playerstats_finddata', [
'type' => $type,
'items' => &$items,
'confid' => $confId,
'fields' => $fields,
'options' => $options,
'configurations' => $configurations,
'configurations' => $request->getConfigurations(),
], $this);

return $items;
Expand All @@ -113,7 +118,7 @@ private function findData($parameters, $configurations, $viewData, $type)
* @param array $fields
* @param array $options
*/
private static function handlePageBrowser(&$configurations, $confid, &$viewdata, &$fields, &$options, $cfg = [])
private static function handlePageBrowser(ConfigurationInterface $configurations, $confid, $viewdata, &$fields, &$options, $cfg = [])
{
$confid .= '.';
if (is_array($configurations->get($confid))) {
Expand All @@ -135,7 +140,8 @@ private static function handlePageBrowser(&$configurations, $confid, &$viewdata,
}
// PageBrowser initialisieren
$pbId = $cfg['pbid'] ? $cfg['pbid'] : 'pb';
$pageBrowser = \tx_rnbase::makeInstance('tx_rnbase_util_PageBrowser', $pbId);

$pageBrowser = tx_rnbase::makeInstance(PageBrowser::class, $pbId);
$pageSize = $configurations->getInt($confid.'limit');

$pageBrowser->setState($configurations->getParameters(), $listSize, $pageSize);
Expand Down
19 changes: 11 additions & 8 deletions Classes/Action/RefereeStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

namespace System25\T3sports\Action;

use Sys25\RnBase\Configuration\ConfigurationInterface;
use Sys25\RnBase\Frontend\Controller\AbstractAction;
use Sys25\RnBase\Frontend\Filter\BaseFilter;
use Sys25\RnBase\Frontend\Request\RequestInterface;
use Sys25\RnBase\Utility\Strings;
use System25\T3sports\Service\StatsServiceRegistry;

/***************************************************************
* Copyright notice
*
* (c) 2010-2020 Rene Nitzsche ([email protected])
* (c) 2010-2022 Rene Nitzsche ([email protected])
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand Down Expand Up @@ -46,15 +49,15 @@ protected function handleRequest(RequestInterface $request)
$viewData = $request->getViewContext();

// Zuerst die Art der Statistik ermitteln
$types = \Tx_Rnbase_Utility_Strings::trimExplode(',', $configurations->get($this->getConfId().'statisticTypes'), 1);
$types = Strings::trimExplode(',', $configurations->get($this->getConfId().'statisticTypes'), 1);
if (!count($types)) {
// Abbruch kein Typ angegeben
throw new \Exception('No statistics type configured in: '.$this->getConfId().'statisticTypes');
}

$statsData = [];
foreach ($types as $type) {
$statsData[$type] = $this->findData($parameters, $configurations, $viewData, $type);
$statsData[$type] = $this->findData($request, $viewData, $type);
}
$viewData->offsetSet('items', $statsData);
$teamId = $configurations->get($this->getConfId().'highlightTeam');
Expand All @@ -68,23 +71,23 @@ protected function handleRequest(RequestInterface $request)
return null;
}

private function findData($parameters, $configurations, $viewData, $type)
private function findData(RequestInterface $request, $viewData, $type)
{
$srv = (new StatsServiceRegistry())->getStatisticService();
$confId = $this->getConfId().$type.'.';
$filter = \tx_rnbase_filter_BaseFilter::createFilter($parameters, $configurations, $viewData, $confId);
$filter = BaseFilter::createFilter($request, $confId);

$fields = [];
$options = [
'enablefieldsoff' => 1,
];
$filter->init($fields, $options);
$debug = $configurations->get($this->getConfId().'options.debug');
$debug = $request->getConfigurations()->get($this->getConfId().'options.debug');
if ($debug) {
$options['debug'] = 1;
}

self::handlePageBrowser($configurations, $confId.'data.pagebrowser', $viewData, $fields, $options, [
self::handlePageBrowser($request->getConfigurations(), $confId.'data.pagebrowser', $viewData, $fields, $options, [
'searchcallback' => [
$srv,
'searchRefereeStats',
Expand All @@ -108,7 +111,7 @@ private function findData($parameters, $configurations, $viewData, $type)
* @param array $fields
* @param array $options
*/
private static function handlePageBrowser(&$configurations, $confid, &$viewdata, &$fields, &$options, $cfg = [])
private static function handlePageBrowser(ConfigurationInterface $configurations, $confid, $viewdata, &$fields, &$options, $cfg = [])
{
$confid .= '.';
if (is_array($configurations->get($confid))) {
Expand Down
17 changes: 12 additions & 5 deletions Classes/Filter/CoachStatsFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

namespace System25\T3sports\Filter;

use Sys25\RnBase\Frontend\Filter\BaseFilter;
use Sys25\RnBase\Utility\Strings;
use System25\T3sports\Search\StatsSearchBuilder;
use System25\T3sports\Utility\ScopeController;

/***************************************************************
* Copyright notice
*
* (c) 2010-2020 Rene Nitzsche
* (c) 2010-2022 Rene Nitzsche
* Contact: [email protected]
* All rights reserved
*
Expand All @@ -31,7 +34,7 @@
*
* @author Rene Nitzsche
*/
class CoachStatsFilter extends \tx_rnbase_filter_BaseFilter
class CoachStatsFilter extends BaseFilter
{
/**
* Abgeleitete Filter können diese Methode überschreiben und zusätzliche Filter setzen.
Expand All @@ -42,11 +45,15 @@ class CoachStatsFilter extends \tx_rnbase_filter_BaseFilter
* @param \tx_rnbase_configurations $configurations
* @param string $confId
*/
protected function initFilter(&$fields, &$options, &$parameters, &$configurations, $confId)
protected function initFilter(&$fields, &$options)
{
$parameters = $this->getParameters();
$configurations = $this->getConfigurations();
$confId = $this->getConfId();

// $options['distinct'] = 1;
// Wir benötigen zuerst die Spalten für WHAT
$cols = \Tx_Rnbase_Utility_Strings::trimExplode(',', $configurations->get($confId.'columns'));
$cols = Strings::trimExplode(',', $configurations->get($confId.'columns'));
$columns = [];
foreach ($cols as $col) {
if ($col) {
Expand All @@ -56,7 +63,7 @@ protected function initFilter(&$fields, &$options, &$parameters, &$configuration
if (count($columns)) {
$options['what'] .= ','.implode(', ', $columns);
}
$scopeArr = \tx_cfcleaguefe_util_ScopeController::handleCurrentScope($parameters, $configurations);
$scopeArr = ScopeController::handleCurrentScope($parameters, $configurations);
StatsSearchBuilder::buildCoachStatsByScope($fields, $scopeArr);
}
}
Loading

0 comments on commit a131954

Please sign in to comment.