Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F679955
DrydockBlueprint.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
DrydockBlueprint.php
View Options
<?php
/**
* @task resource Allocating Resources
* @task lease Acquiring Leases
*/
final
class
DrydockBlueprint
extends
DrydockDAO
implements
PhabricatorApplicationTransactionInterface
,
PhabricatorPolicyInterface
,
PhabricatorCustomFieldInterface
{
protected
$className
;
protected
$blueprintName
;
protected
$viewPolicy
;
protected
$editPolicy
;
protected
$details
=
array
();
private
$implementation
=
self
::
ATTACHABLE
;
private
$customFields
=
self
::
ATTACHABLE
;
private
$fields
=
null
;
public
static
function
initializeNewBlueprint
(
PhabricatorUser
$actor
)
{
$app
=
id
(
new
PhabricatorApplicationQuery
())
->
setViewer
(
$actor
)
->
withClasses
(
array
(
'PhabricatorDrydockApplication'
))
->
executeOne
();
$view_policy
=
$app
->
getPolicy
(
DrydockDefaultViewCapability
::
CAPABILITY
);
$edit_policy
=
$app
->
getPolicy
(
DrydockDefaultEditCapability
::
CAPABILITY
);
return
id
(
new
DrydockBlueprint
())
->
setViewPolicy
(
$view_policy
)
->
setEditPolicy
(
$edit_policy
)
->
setBlueprintName
(
''
);
}
protected
function
getConfiguration
()
{
return
array
(
self
::
CONFIG_AUX_PHID
=>
true
,
self
::
CONFIG_SERIALIZATION
=>
array
(
'details'
=>
self
::
SERIALIZATION_JSON
,
),
self
::
CONFIG_COLUMN_SCHEMA
=>
array
(
'className'
=>
'text255'
,
'blueprintName'
=>
'sort255'
,
),
)
+
parent
::
getConfiguration
();
}
public
function
generatePHID
()
{
return
PhabricatorPHID
::
generateNewPHID
(
DrydockBlueprintPHIDType
::
TYPECONST
);
}
public
function
getImplementation
()
{
return
$this
->
assertAttached
(
$this
->
implementation
);
}
public
function
attachImplementation
(
DrydockBlueprintImplementation
$impl
)
{
$this
->
implementation
=
$impl
;
return
$this
;
}
public
function
getDetail
(
$key
,
$default
=
null
)
{
return
idx
(
$this
->
details
,
$key
,
$default
);
}
public
function
setDetail
(
$key
,
$value
)
{
$this
->
details
[
$key
]
=
$value
;
return
$this
;
}
public
function
getFieldValue
(
$key
)
{
$key
=
"std:drydock:core:{$key}"
;
$fields
=
$this
->
loadCustomFields
();
$field
=
idx
(
$fields
,
$key
);
if
(!
$field
)
{
throw
new
Exception
(
pht
(
'Unknown blueprint field "%s"!'
,
$key
));
}
return
$field
->
getBlueprintFieldValue
();
}
private
function
loadCustomFields
()
{
if
(
$this
->
fields
===
null
)
{
$field_list
=
PhabricatorCustomField
::
getObjectFields
(
$this
,
PhabricatorCustomField
::
ROLE_VIEW
);
$field_list
->
readFieldsFromStorage
(
$this
);
$this
->
fields
=
$field_list
->
getFields
();
}
return
$this
->
fields
;
}
/* -( Allocating Resources )----------------------------------------------- */
/**
* @task resource
*/
public
function
canEverAllocateResourceForLease
(
DrydockLease
$lease
)
{
return
$this
->
getImplementation
()->
canEverAllocateResourceForLease
(
$this
,
$lease
);
}
/**
* @task resource
*/
public
function
canAllocateResourceForLease
(
DrydockLease
$lease
)
{
return
$this
->
getImplementation
()->
canAllocateResourceForLease
(
$this
,
$lease
);
}
/**
* @task resource
*/
public
function
allocateResource
(
DrydockLease
$lease
)
{
return
$this
->
getImplementation
()->
allocateResource
(
$this
,
$lease
);
}
/* -( Acquiring Leases )--------------------------------------------------- */
/**
* @task lease
*/
public
function
canAcquireLeaseOnResource
(
DrydockResource
$resource
,
DrydockLease
$lease
)
{
return
$this
->
getImplementation
()->
canAcquireLeaseOnResource
(
$this
,
$resource
,
$lease
);
}
/**
* @task lease
*/
public
function
acquireLease
(
DrydockResource
$resource
,
DrydockLease
$lease
)
{
return
$this
->
getImplementation
()->
acquireLease
(
$this
,
$resource
,
$lease
);
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public
function
getApplicationTransactionEditor
()
{
return
new
DrydockBlueprintEditor
();
}
public
function
getApplicationTransactionObject
()
{
return
$this
;
}
public
function
getApplicationTransactionTemplate
()
{
return
new
DrydockBlueprintTransaction
();
}
public
function
willRenderTimeline
(
PhabricatorApplicationTransactionView
$timeline
,
AphrontRequest
$request
)
{
return
$timeline
;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public
function
getCapabilities
()
{
return
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
);
}
public
function
getPolicy
(
$capability
)
{
switch
(
$capability
)
{
case
PhabricatorPolicyCapability
::
CAN_VIEW
:
return
$this
->
getViewPolicy
();
case
PhabricatorPolicyCapability
::
CAN_EDIT
:
return
$this
->
getEditPolicy
();
}
}
public
function
hasAutomaticCapability
(
$capability
,
PhabricatorUser
$viewer
)
{
return
false
;
}
public
function
describeAutomaticCapability
(
$capability
)
{
return
null
;
}
/* -( PhabricatorCustomFieldInterface )------------------------------------ */
public
function
getCustomFieldSpecificationForRole
(
$role
)
{
return
array
();
}
public
function
getCustomFieldBaseClass
()
{
return
'DrydockBlueprintCustomField'
;
}
public
function
getCustomFields
()
{
return
$this
->
assertAttached
(
$this
->
customFields
);
}
public
function
attachCustomFields
(
PhabricatorCustomFieldAttachment
$fields
)
{
$this
->
customFields
=
$fields
;
return
$this
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 27, 8:53 AM (1 d, 15 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
170468
Default Alt Text
DrydockBlueprint.php (5 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment