Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2891989
PhabricatorChartDataset.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorChartDataset.php
View Options
<?php
abstract
class
PhabricatorChartDataset
extends
Phobject
{
private
$functions
;
final
public
function
getDatasetTypeKey
(
)
{
return
$this
->
getPhobjectClassConstant
(
'DATASETKEY'
,
32
)
;
}
final
public
function
getFunctions
(
)
{
return
$this
->
functions
;
}
final
public
function
setFunctions
(
array
$functions
)
{
assert_instances_of
(
$functions
,
'PhabricatorComposeChartFunction'
)
;
$this
->
functions
=
$functions
;
return
$this
;
}
final
public
static
function
getAllDatasetTypes
(
)
{
return
id
(
new
PhutilClassMapQuery
(
)
)
->
setAncestorClass
(
__CLASS__
)
->
setUniqueMethod
(
'getDatasetTypeKey'
)
->
execute
(
)
;
}
final
public
static
function
newFromDictionary
(
array
$map
)
{
PhutilTypeSpec
::
checkMap
(
$map
,
array
(
'type'
=>
'string'
,
'functions'
=>
'list<wild>'
,
)
)
;
$types
=
self
::
getAllDatasetTypes
(
)
;
$dataset_type
=
$map
[
'type'
]
;
if
(
!
isset
(
$types
[
$dataset_type
]
)
)
{
throw
new
Exception
(
pht
(
'Trying to construct a dataset of type "%s", but this type is '
.
'unknown. Supported types are: %s.'
,
$dataset_type
,
implode
(
', '
,
array_keys
(
$types
)
)
)
)
;
}
$dataset
=
id
(
clone
$types
[
$dataset_type
]
)
;
$functions
=
array
(
)
;
foreach
(
$map
[
'functions'
]
as
$map
)
{
$functions
[
]
=
PhabricatorChartFunction
::
newFromDictionary
(
$map
)
;
}
$dataset
->
setFunctions
(
$functions
)
;
return
$dataset
;
}
final
public
function
getChartDisplayData
(
PhabricatorChartDataQuery
$data_query
)
{
return
$this
->
newChartDisplayData
(
$data_query
)
;
}
abstract
protected
function
newChartDisplayData
(
PhabricatorChartDataQuery
$data_query
)
;
final
public
function
getTabularDisplayData
(
PhabricatorChartDataQuery
$data_query
)
{
$results
=
array
(
)
;
$functions
=
$this
->
getFunctions
(
)
;
foreach
(
$functions
as
$function
)
{
$datapoints
=
$function
->
newDatapoints
(
$data_query
)
;
$refs
=
$function
->
getDataRefs
(
ipull
(
$datapoints
,
'x'
)
)
;
foreach
(
$datapoints
as
$key
=>
$point
)
{
$x
=
$point
[
'x'
]
;
if
(
isset
(
$refs
[
$x
]
)
)
{
$xrefs
=
$refs
[
$x
]
;
}
else
{
$xrefs
=
array
(
)
;
}
$datapoints
[
$key
]
[
'refs'
]
=
$xrefs
;
}
$results
[
]
=
array
(
'data'
=>
$datapoints
,
)
;
}
return
id
(
new
PhabricatorChartDisplayData
(
)
)
->
setWireData
(
$results
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 16:02 (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126292
Default Alt Text
PhabricatorChartDataset.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment