diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2015-01-29 06:48:23 +0300 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2015-02-13 08:23:10 +0300 |
commit | 8ef47c8e4a3fb0094b4b0c19df8ed18c58cf7a6f (patch) | |
tree | 162315afc7f5a5bc0c8840eff30251a76b665b6f /core/DataTable/Filter/ColumnCallbackDeleteMetadata.php | |
parent | ec8dc0f150d71b752188dac3d01d29950ae6f869 (diff) |
refs #4633 open segmented visitor log with one click on a row
Diffstat (limited to 'core/DataTable/Filter/ColumnCallbackDeleteMetadata.php')
-rw-r--r-- | core/DataTable/Filter/ColumnCallbackDeleteMetadata.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/core/DataTable/Filter/ColumnCallbackDeleteMetadata.php b/core/DataTable/Filter/ColumnCallbackDeleteMetadata.php new file mode 100644 index 0000000000..dc37f96016 --- /dev/null +++ b/core/DataTable/Filter/ColumnCallbackDeleteMetadata.php @@ -0,0 +1,51 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ +namespace Piwik\DataTable\Filter; + +use Piwik\DataTable; +use Piwik\DataTable\BaseFilter; + +/** + * Executes a callback for each row of a {@link DataTable} and removes the defined metadata column from each row. + * + * **Basic usage example** + * + * $dataTable->filter('ColumnCallbackDeleteMetadata', array('segmentValue')); + * + * @api + */ +class ColumnCallbackDeleteMetadata extends BaseFilter +{ + private $metadataToRemove; + + /** + * Constructor. + * + * @param DataTable $table The DataTable instance that will be filtered. + * @param string $metadataToRemove The name of the metadata field that will be removed from each row. + */ + public function __construct($table, $metadataToRemove) + { + parent::__construct($table); + + $this->metadataToRemove = $metadataToRemove; + } + + /** + * See {@link ColumnCallbackDeleteMetadata}. + * + * @param DataTable $table + */ + public function filter($table) + { + foreach ($table->getRows() as $row) { + $row->deleteMetadata($this->metadataToRemove); + } + } +} |