PHP Class Piwik\Archive\DataTableFactory

This class is only used by DataCollection.
ファイルを表示 Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
__construct ( $dataNames, $dataType, $sitesId, $periods, $defaultRow ) Constructor.
expandDataTable ( null | integer $maxSubtableDepth = null, boolean $addMetadataSubtableId = false ) Tells the factory instance to expand the DataTables that are created by creating subtables and setting the subtable IDs of rows w/ subtables correctly.
getSiteIdFromMetadata ( DataTable $table ) : integer | null Returns the ID of the site a table is related to based on the 'site' metadata entry, or null if there is none.
make ( array $index, array $resultIndices ) : DataTable | Piwik\DataTable\Map Creates a DataTable|Set instance using an index of archive data.
makeMerged ( array $index, array $resultIndices ) : DataTable | Piwik\DataTable\Map Creates a merged DataTable|Map instance using an index of archive data similar to {@link make()}.
useSubtable ( integer $idSubtable ) Tells the factory instance to create a DataTable using a blob with the supplied subtable ID.

Private Methods

Method Description
createDataTable ( array $data, array $keyMetadata ) : DataTable | Piwik\DataTable\Map Creates a DataTable instance from an index row.
createDataTableMapFromIndex ( array $index, array $resultIndices, array $keyMetadata ) : Piwik\DataTable\Map Creates a Set from an array index.
createTableIndexMetadata ( $resultIndex, $label )
getDefaultMetadata ( )
isNumericDataType ( )
makeDataTableFromSingleBlob ( array $blobRow, $keyMetadata ) : DataTable Creates a DataTable for one record from an archive data row.
makeFromBlobRow ( array $blobRow, $keyMetadata ) : DataTable | Piwik\DataTable\Map Creates a DataTable|Set instance using an array of blobs.
makeFromMetricsArray ( $data, $keyMetadata ) : Piwik\DataTable\Simple
makeIndexedByRecordNameDataTable ( array $blobRow, $keyMetadata ) : Piwik\DataTable\Map Creates a DataTable for every record in an archive data row and puts them in a DataTable\Map instance.
makeMergedTableWithPeriodAndSiteIndex ( $index, $resultIndices, $useSimpleDataTable, $isNumeric )
makeMergedWithSiteIndex ( $index, $useSimpleDataTable, $isNumeric )
prettifyIndexLabel ( string $labelType, string $label ) : string Returns the pretty version of an index label.
setSubtables ( DataTable $dataTable, array $blobRow, integer $treeLevel ) Creates DataTables from $dataTable's subtable blobs (stored in $blobRow) and sets the subtable IDs of each DataTable row.

Method Details

__construct() public method

Constructor.
public __construct ( $dataNames, $dataType, $sitesId, $periods, $defaultRow )

expandDataTable() public method

Tells the factory instance to expand the DataTables that are created by creating subtables and setting the subtable IDs of rows w/ subtables correctly.
public expandDataTable ( null | integer $maxSubtableDepth = null, boolean $addMetadataSubtableId = false )
$maxSubtableDepth null | integer max depth for subtables.
$addMetadataSubtableId boolean Whether to add the subtable ID used in the database to the in-memory DataTables as metadata or not.

getSiteIdFromMetadata() public static method

Returns the ID of the site a table is related to based on the 'site' metadata entry, or null if there is none.
public static getSiteIdFromMetadata ( DataTable $table ) : integer | null
$table Piwik\DataTable
return integer | null

make() public method

Creates a DataTable|Set instance using an index of archive data.
public make ( array $index, array $resultIndices ) : DataTable | Piwik\DataTable\Map
$index array @see DataCollection
$resultIndices array an array mapping metadata names with pretty metadata labels.
return Piwik\DataTable | Piwik\DataTable\Map

makeMerged() public method

Whereas {@link make()} creates a Map for each result index (period and|or site), this will only create a Map for a period result index and move all site related indices into one dataTable. This is the same as doing $dataTableFactory->make()->mergeChildren() just much faster. It is mainly useful for reports across many sites eg MultiSites.getAll. Was done as part of https://github.com/piwik/piwik/issues/6809
public makeMerged ( array $index, array $resultIndices ) : DataTable | Piwik\DataTable\Map
$index array @see DataCollection
$resultIndices array an array mapping metadata names with pretty metadata labels.
return Piwik\DataTable | Piwik\DataTable\Map

useSubtable() public method

Tells the factory instance to create a DataTable using a blob with the supplied subtable ID.
public useSubtable ( integer $idSubtable )
$idSubtable integer An in-database subtable ID.