ReportDimension represents a report data source dimension.

Public Methods

public __construct()

public __construct(
    string $code,
    string $databaseColumnName,
    string $displayName,
    ?string $labelColumnName = null
): void

Creates a new dimension instance.

public addCalculatedMetric()

public addCalculatedMetric(
    string $displayName,
): ReportDimension 

A shorthand version of addDimensionMetric. Adds a calculated metric that doesn't work with the database.

public addDimensionField()

public addDimensionField(ReportDimensionField $field): $this 

Adds a field to this dimension.

public addDimensionMetric()

public addDimensionMetric(ReportMetric $metric): ReportDimension 

Registers a dimension metric.

public static findDimensionByCode()

public static findDimensionByCode(
    array $availableDimensions,
    string $dimensionCode,
    ?bool $strict = true
): ?ReportDimension 

Finds a dimension by its code.

public findDimensionFieldByCode()

public findDimensionFieldByCode(
    string $dimensionFieldCode
): ReportDimensionField 

Finds a dimension field by its code.

public getAvailableMetrics()

public getAvailableMetrics(): ReportMetric[] 

Returns the available metrics for this dimension.

public getCacheUniqueCode()

public getCacheUniqueCode(): string 

Returns code unique for this dimension to be used as a part of a cache key.

public getCode()

public getCode(): string 

Returns the dimension code.

public getDataSetColumName()

public getDataSetColumName(): string 

Returns a query column name corresponding to this dimension.

public getDatabaseColumnName()

public getDatabaseColumnName(): string 

Returns the database column name for this dimension.

public getDefaultWidgetConfig()

public getDefaultWidgetConfig(): array 

getDefaultWidgetConfig returns the default widget configuration.

public getDimensionFields()

public getDimensionFields(): ReportDimensionField[] 

Returns fields of the dimension.

public getDimensionType()

public getDimensionType(): ?string 

Returns the dimension type.

public getDisplayName()

public getDisplayName(): string 

Returns the dimension display name.

public getLabelColumnName()

public getLabelColumnName(): ?string 

Returns the dimension label column name.

public getMonthGroupingField()

public getMonthGroupingField(): string 

Gets the name of the column containing month start dates.

public getQuarterGroupingField()

public getQuarterGroupingField(): string 

Gets the name of the column containing quarter start dates.

public getWeekGroupingField()

public getWeekGroupingField(): string 

Gets the name of the column containing week start dates.

public getYearGroupingField()

public getYearGroupingField(): string 

Gets the name of the column containing year start dates.

public isDate()

public isDate(): bool 

Checks if this is a date dimension.

public setDateIntervalGroupingFields()

public setDateIntervalGroupingFields(
    string $weekField,
    string $monthField,
    string $quarterField,
    string $yearField
): void

Allows setting of custom field names for building queries that group data by week, month, quarter, and year intervals. If the fields are not set, ReportDataQueryBuilder will use SQL functions to deduce interval start dates from the dimension column value. This approach is less efficient than using indexed columns. The names specified in the arguments must refer to columns containing start dates for the corresponding intervals in the YYYY-MM-DD format. For example, the year column should contain values like 2023-01-01, 2024-01-01, etc.

public setDefaultWidgetConfig()

public setDefaultWidgetConfig(array $config): ReportDimension 

Allows setting default widget configuration values. The configuration is used for widgets created from this dimension through the quick widget creation feature. Currently, the future supports indicator-type dimensions only.