Filter data

@param Table $table
358412
public function filter(Table $table)
    {
        $filters = $table->getFilters();
        if (count($filters) == 0)
            return;

        $columns = $table->getColumns();
        $result = [];
        foreach ($this->data as $row) {
            $passedAnds = true;
            foreach ($filters as $id => $filterData) {
                $passedOrs = false;
                foreach ($filterData as $name => $value) {
                    $real = $row[$id];
                    if ($real && $columns[$id]['type'] == Table::TYPE_DATETIME) {
                        if (is_string($real)) {
                            if ($this->getDbTimezone())
                                $real = new \DateTime($real, new \DateTimeZone($this->getDbTimezone()));
                            else
                                $real = new \DateTime($real);
                        } else if (is_int($real)) {
                            $real = new \DateTime('@' . $real);
                        }
                        if (date_default_timezone_get())
                            $real->setTimezone(new \DateTimeZone(date_default_timezone_get()));
                    }
                    $test = $this->checkFilter($name, $columns[$id]['type'], $value, $real);
                    if ($test === true)
                        $passedOrs = true;
                }
                if (!$passedOrs)
                    $passedAnds = false;
            }
            if ($passedAnds)
                $result[] = $row;
        }

        $this->data = $result;
    }
295012
public function filter($table)
    {
        if (empty($this->segments)) {
            $msg = 'AddSegmentByLabel is called without having any segments defined';
            Development::error($msg);
            return;
        }

        if (count($this->segments) === 1) {
            $segment = reset($this->segments);

            foreach ($table->getRowsWithoutSummaryRow() as $key => $row) {
                $label = $row->getColumn('label');

                if (!empty($label)) {
                    $row->setMetadata('segment', $segment . '==' . urlencode($label));
                }
            }
        } elseif (!empty($this->delimiter)) {
            $numSegments  = count($this->segments);
            $conditionAnd = ';';

            foreach ($table->getRowsWithoutSummaryRow() as $key => $row) {
                $label = $row->getColumn('label');
                if (!empty($label)) {
                    $parts = explode($this->delimiter, $label);

                    if (count($parts) === $numSegments) {
                        $filter = array();
                        foreach ($this->segments as $index => $segment) {
                            if (!empty($segment)) {
                                $filter[] = $segment . '==' . urlencode($parts[$index]);
                            }
                        }
                        $row->setMetadata('segment', implode($conditionAnd, $filter));
                    }
                }
            }
        } else {
            $names = implode(', ', $this->segments);
            $msg   = 'Multiple segments are given but no delimiter defined. Segments: ' . $names;
            Development::error($msg);
        }
    }
922119
public function filter($table)
    {
        foreach ($table->getRows() as $row) {
            $value = $this->getDividend($row);
            if ($value === false && $this->shouldSkipRows) {
                continue;
            }

            // Delete existing column if it exists
            $existingValue = $row->getColumn($this->columnNameToAdd);
            if ($existingValue !== false) {
                continue;
            }

            $divisor = $this->getDivisor($row);

            $formattedValue = $this->formatValue($value, $divisor);
            $row->addColumn($this->columnNameToAdd, $formattedValue);

            $this->filterSubTable($row);
        }
    }
1208937
public function delete($table)
	{
		if (in_array($table, $this->tablesToDelete) === false) {
			$this->tablesToDelete[] = $table;
		}

		return $this;
	}
500662
private function CleanForeignKeys($table)
    {
        $foreignKeys = $this->connection->GetForeignKeys($table);
        foreach ($foreignKeys as $foreignKey)
        {
            $this->connection->DropForeignKey($table, $foreignKey);
        }
    }
404644
protected function clearData($table, $clearLinks = false)
    {
        if ($this->option('clear')) {
            $this->db->statement('SET FOREIGN_KEY_CHECKS=0;');

            $this->db->table($table)->truncate();

            if ($clearLinks) {
                $this->db->table('table_links')->where('new_table', $table)->delete();
            }

            $this->db->statement('SET FOREIGN_KEY_CHECKS=1;');
        }
    }
294715
def filter(self, table, domains, filter_string):
        """"""
        q = filter_string.lower()

        def comp(domain):
            if q in domain.name.lower():
                return True
            return False

        return filter(comp, domains)
1232681
protected function filterKey($table, $name)
    {
        if (!$this->options[self::OPTION_FILTER_KEY]) {
            return false;
        }
        $primaryKey = $table->getPrimaryKey();
        if (!is_array($primaryKey)) {
            $primaryKey = [$primaryKey];
        }
        return in_array($name, $primaryKey);
    }
1217006
public function filter($table)
    {
        if ($this->applyToSummaryRow) {
            $rows = $table->getRows();
        } else {
            $rows = $table->getRowsWithoutSummaryRow();
        }

        foreach ($rows as $key => $row) {
            $parameters = array();
            foreach ($this->columnsToRead as $columnsToRead) {
                $parameters[] = $row->getColumn($columnsToRead);
            }

            if (!is_null($this->functionParameters)) {
                $parameters = array_merge($parameters, $this->functionParameters);
            }
            if (!is_null($this->functionToApply)) {
                $newValue = call_user_func_array($this->functionToApply, $parameters);
            } else {
                $newValue = $parameters[0];
            }
            if ($newValue !== false) {
                $row->addMetadata($this->metadataToAdd, $newValue);
            }
        }
    }
1187390
public function filter($table)
    {
        $rows = $table->getRows();

        foreach ($rows as $key => $row) {
            // A row is deleted if
            // 1 - its label doesn't contain the pattern
            // AND 2 - the label is not found in the children
            $patternNotFoundInChildren = false;

            $subTable = $row->getSubtable();
            if (!$subTable) {
                $patternNotFoundInChildren = true;
            } else {
                // we delete the row if we couldn't find the pattern in any row in the
                // children hierarchy
                if ($this->filter($subTable) == 0) {
                    $patternNotFoundInChildren = true;
                }
            }

            if ($patternNotFoundInChildren
                && !Pattern::match($this->patternToSearchQuoted, $row->getColumn($this->columnToFilter), $invertedMatch = false)
            ) {
                $table->deleteRow($key);
            }
        }

        return $table->getRowsCount();
    }
18234
public function visitTable(TableInterface $table)
    {
        $template = 'table/base.twig';

        $filters = [];
        for ($thisFilter = $table->getFilter(); $thisFilter !== null; $thisFilter = $thisFilter->getNextFilter()) {
            $filters[] = $thisFilter;
        }

        return $this
            ->loadTemplate($template)
            ->render(
                [
                    "id" => $table->getId(),
                    "classes" => $table->getClasses(),
                    "data" => $table->getData(),
                    "rows" => $table->getRows(),
                    "filters" => $filters,
                ]
            );
    }
848890
protected function createTable(Table $table): void
	{
		$table->addPrimaryKey('id')
			->int()
			->setAutoIncrement();
		$table->addForeignKey('pageId', PagesMapper::class);
		$table->addColumn('name')
			->varChar();
		$table->addColumn('position')
			->int(3);
	}
476838
public function check(Table $table)
    {
        foreach ($table->getColumns() as $id => $params) {
            if (!isset($params['sql_id']))
                throw new \Exception("No 'sql_id' param for ID $id");
        }

        $backupSqlWhere = $this->sqlWhere;
        $backupSqlParams = $this->sqlParams;

        $columns = $table->getColumns();
        $successfulFilters = [];
        foreach ($table->getFilters() as $column => $filters) {
            $successfulNames = [];
            foreach ($filters as $name => $value) {
                if ($this->buildFilter($columns[$column]['sql_id'], $columns[$column]['type'], $name, $value))
                    $successfulNames[$name] = $value;
            }
            if (count($successfulNames) > 0)
                $successfulFilters[$column] = $successfulNames;
        }
        $table->setFilters($successfulFilters);

        $this->sqlWhere = $backupSqlWhere;
        $this->sqlParams = $backupSqlParams;
    }
958269
public function drop(string $table)
    {
        $compiler = $this->connection->schemaCompiler();

        $result = $compiler->drop($table);

        $this->connection->command($result['sql'], $result['params']);

        //clear table list
        $this->tableList = null;
        unset($this->columns[strtolower($table)]);
    }
1347043
public function filter($table)
    {
        // always do recursive filter
        $this->enableRecursive(true);
        $recurse = false; // only recurse if there are columns to remove/keep

        // remove columns specified in $this->columnsToRemove
        if (!empty($this->columnsToRemove)) {
            $this->removeColumnsFromTable($table);
            $recurse = true;
        }

        // remove columns not specified in $columnsToKeep
        if (!empty($this->columnsToKeep)) {
            foreach ($table as $index => $row) {
                $columnsToDelete = array();
                foreach ($row as $name => $value) {
                    $keep = false;

                    // @see self::APPEND_TO_COLUMN_NAME_TO_KEEP
                    foreach ($this->columnsToKeep as $nameKeep => $true) {
                        if (strpos($name, $nameKeep . self::APPEND_TO_COLUMN_NAME_TO_KEEP) === 0) {
                            $keep = true;
                        }
                    }

                    if (!$keep
                        && $name != 'label' // label cannot be removed via whitelisting
                        && !isset($this->columnsToKeep[$name])
                    ) {
                        // we cannot remove row directly to prevent notice "ArrayIterator::next(): Array was modified
                        // outside object and internal position is no longer valid in /var/www..."
                        $columnsToDelete[] = $name;
                    }
                }
                foreach ($columnsToDelete as $columnToDelete) {
                    unset($table[$index][$columnToDelete]);
                }
            }

            $recurse = true;
        }

        // recurse
        if ($recurse && !is_array($table)) {
            foreach ($table as $row) {
                $this->filterSubTable($row);
            }
        }

        return $table;
    }
51171
protected function skipMonitoringOfTable($table)
    {
        static $configurationMonitorTables;

        if (empty($configurationMonitorTables)) {
            $configuration = GeneralUtility::makeInstance(ExtensionConfiguration::class);
            $configurationMonitorTables = $configuration->getIsUseConfigurationMonitorTables();
        }

        // No explicit configuration => all tables should be monitored
        if (empty($configurationMonitorTables)) {
            return false;
        }

        return !in_array($table, $configurationMonitorTables);
    }
1253378
public function collect(Table $table)
    {
        foreach ($table->getForeignKeys() as $foreignKey) {
            $this->dropForeignKeyQueries = array_merge(
                $this->dropForeignKeyQueries,
                $this->platform->getDropForeignKeySQLQueries($foreignKey, $table->getName())
            );
        }

        $this->dropTableQueries = array_merge(
            $this->dropTableQueries,
            $this->platform->getDropTableSQLQueries($table)
        );
    }