Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2896667
SemiStructuredObjectInstanceQuery.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
SemiStructuredObjectInstanceQuery.php
View Options
<?php
final
class
SemiStructuredObjectInstanceQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
private
$ids
;
private
$phids
;
private
$classPHIDs
;
private
$statuses
;
private
$canEdit
;
private
?
SemiStructuredObjectType
$objectType
=
null
;
public
function
withIDs
(
array
$ids
)
{
$this
->
ids
=
$ids
;
return
$this
;
}
public
function
withPHIDs
(
array
$phids
)
{
$this
->
phids
=
$phids
;
return
$this
;
}
public
function
withObjectType
(
SemiStructuredObjectType
$object_type
)
{
$this
->
objectType
=
$object_type
;
return
$this
->
withClassPHIDs
(
array
(
$object_type
->
getPHID
()));
}
public
function
withClassPHIDs
(
array
$class_phids
)
{
$this
->
classPHIDs
=
$class_phids
;
return
$this
;
}
public
function
withStatuses
(
array
$statuses
)
{
$this
->
statuses
=
$statuses
;
return
$this
;
}
public
function
withCanEdit
(
$can_edit
)
{
$this
->
canEdit
=
$can_edit
;
return
$this
;
}
public
function
newResultObject
()
{
$instance
=
new
SemiStructuredObjectInstance
();
if
(
$this
->
objectType
)
{
$instance
->
attachClass
(
$this
->
objectType
);
}
return
$instance
;
}
protected
function
didFilterPage
(
array
$items
)
{
$phids
=
mpull
(
$items
,
'getPHID'
);
if
(
$this
->
canEdit
)
{
$items
=
id
(
new
PhabricatorPolicyFilter
())
->
setViewer
(
$this
->
getViewer
())
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
apply
(
$items
);
}
return
$items
;
}
protected
function
buildWhereClauseParts
(
AphrontDatabaseConnection
$conn
)
{
$where
=
parent
::
buildWhereClauseParts
(
$conn
);
if
(
$this
->
ids
!==
null
)
{
$where
[]
=
qsprintf
(
$conn
,
'instances.id IN (%Ld)'
,
$this
->
ids
);
}
if
(
$this
->
phids
!==
null
)
{
$where
[]
=
qsprintf
(
$conn
,
'instances.phid IN (%Ls)'
,
$this
->
phids
);
}
if
(
$this
->
classPHIDs
!==
null
)
{
$where
[]
=
qsprintf
(
$conn
,
'instances.classPHID IN (%Ls)'
,
$this
->
classPHIDs
);
}
if
(
$this
->
statuses
!==
null
)
{
$where
[]
=
qsprintf
(
$conn
,
'instances.status IN (%Ls)'
,
$this
->
statuses
);
}
return
$where
;
}
protected
function
willFilterPage
(
array
$objects
)
{
$classes
=
id
(
new
SemiStructuredObjectTypeQuery
())
->
setViewer
(
$this
->
getViewer
())
->
withPHIDs
(
mpull
(
$objects
,
'getClassPHID'
))
->
execute
();
$classes
=
mpull
(
$classes
,
null
,
'getPHID'
);
foreach
(
$objects
as
$key
=>
$object
)
{
$class
=
idx
(
$classes
,
$object
->
getClassPHID
());
if
(!
$class
)
{
unset
(
$objects
[
$key
]);
continue
;
}
$object
->
attachClass
(
$class
);
}
return
$objects
;
}
public
function
getQueryApplicationClass
()
{
return
'SemiStructuredDataApplication'
;
}
protected
function
getPrimaryTableAlias
()
{
return
'instances'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 23:24 (6 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1129871
Default Alt Text
SemiStructuredObjectInstanceQuery.php (2 KB)
Attached To
Mode
R6 Semi Structured
Attached
Detach File
Event Timeline
Log In to Comment