Skip to content

Commit

Permalink
rex_list: refactor logic into new getEnabledColumnNames() method (#5825)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Sep 29, 2023
1 parent 74be1b7 commit 31929eb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
5 changes: 0 additions & 5 deletions .tools/phpstan/baseline.neon
Expand Up @@ -1930,11 +1930,6 @@ parameters:
count: 1
path: ../../redaxo/src/core/lib/list.php

-
message: "#^Method rex_list\\:\\:getColumnNames\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: ../../redaxo/src/core/lib/list.php

-
message: "#^Method rex_list\\:\\:getColumnParams\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
18 changes: 0 additions & 18 deletions .tools/psalm/baseline.xml
Expand Up @@ -4014,15 +4014,6 @@
<code>$column</code>
<code>$column</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code><![CDATA[$column['span'] ?? null]]></code>
<code><![CDATA[$column['width'] ?? null]]></code>
<code>$format[0]</code>
Expand All @@ -4040,22 +4031,13 @@
<code>$groupColumns[]</code>
</MixedArrayAssignment>
<MixedArrayOffset>
<code>$columnFormates[$columnName]</code>
<code>$columnFormates[$columnName]</code>
<code><![CDATA[$this->customColumns[$columnName]]]></code>
<code><![CDATA[$this->customColumns[$columnName]]]></code>
<code><![CDATA[$this->customColumns[$column]]]></code>
<code><![CDATA[$this->linkAttributes[$columnName]]]></code>
<code><![CDATA[$this->linkAttributes[$columnName][$attrName]]]></code>
<code><![CDATA[$this->linkAttributes[$column]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code>$column</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnName</code>
<code>$columnNames[]</code>
<code>$columnSortType</code>
<code>$flatParams[$name]</code>
<code>$flatParams[$name]</code>
Expand Down
24 changes: 17 additions & 7 deletions redaxo/src/core/lib/list.php
Expand Up @@ -491,13 +491,28 @@ public function getColumnName($columnIndex, $default = null)
/**
* Gibt alle Namen der Spalten als Array zurück.
*
* @return array
* @return list<string>
*/
public function getColumnNames()
{
return $this->columnNames;
}

/**
* @return list<string>
*/
protected function getEnabledColumnNames(): array
{
$columnNames = [];
foreach ($this->getColumnNames() as $columnName) {
if (!in_array($columnName, $this->columnDisabled)) {
$columnNames[] = $columnName;
}
}

return $columnNames;
}

/**
* Setzt ein Label für eine Spalte.
*
Expand Down Expand Up @@ -1149,12 +1164,7 @@ public function get()

// Columns vars
$columnFormates = [];
$columnNames = [];
foreach ($this->getColumnNames() as $columnName) {
if (!in_array($columnName, $this->columnDisabled)) {
$columnNames[] = $columnName;
}
}
$columnNames = $this->getEnabledColumnNames();

// List vars
$sortColumn = $this->getSortColumn();
Expand Down

0 comments on commit 31929eb

Please sign in to comment.