Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96219567
HarbormasterPublishFragmentBuildStepImplementation.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 23, 21:32
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 21:32 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23139933
Attached To
rPH Phabricator
HarbormasterPublishFragmentBuildStepImplementation.php
View Options
<?php
final
class
HarbormasterPublishFragmentBuildStepImplementation
extends
HarbormasterBuildStepImplementation
{
public
function
getName
()
{
return
pht
(
'Publish Fragment'
);
}
public
function
getGenericDescription
()
{
return
pht
(
'Publish a fragment based on a file artifact.'
);
}
public
function
getBuildStepGroupKey
()
{
return
HarbormasterPrototypeBuildStepGroup
::
GROUPKEY
;
}
public
function
getDescription
()
{
return
pht
(
'Publish file artifact %s as fragment %s.'
,
$this
->
formatSettingForDescription
(
'artifact'
),
$this
->
formatSettingForDescription
(
'path'
));
}
public
function
execute
(
HarbormasterBuild
$build
,
HarbormasterBuildTarget
$build_target
)
{
$settings
=
$this
->
getSettings
();
$variables
=
$build_target
->
getVariables
();
$viewer
=
PhabricatorUser
::
getOmnipotentUser
();
$path
=
$this
->
mergeVariables
(
'vsprintf'
,
$settings
[
'path'
],
$variables
);
$artifact
=
$build_target
->
loadArtifact
(
$settings
[
'artifact'
]);
$impl
=
$artifact
->
getArtifactImplementation
();
$file
=
$impl
->
loadArtifactFile
(
$viewer
);
$fragment
=
id
(
new
PhragmentFragmentQuery
())
->
setViewer
(
$viewer
)
->
withPaths
(
array
(
$path
))
->
executeOne
();
if
(
$fragment
===
null
)
{
PhragmentFragment
::
createFromFile
(
$viewer
,
$file
,
$path
,
PhabricatorPolicies
::
getMostOpenPolicy
(),
PhabricatorPolicies
::
POLICY_USER
);
}
else
{
if
(
$file
->
getMimeType
()
===
'application/zip'
)
{
$fragment
->
updateFromZIP
(
$viewer
,
$file
);
}
else
{
$fragment
->
updateFromFile
(
$viewer
,
$file
);
}
}
}
public
function
getArtifactInputs
()
{
return
array
(
array
(
'name'
=>
pht
(
'Publishes File'
),
'key'
=>
$this
->
getSetting
(
'artifact'
),
'type'
=>
HarbormasterFileArtifact
::
ARTIFACTCONST
,
),
);
}
public
function
getFieldSpecifications
()
{
return
array
(
'path'
=>
array
(
'name'
=>
pht
(
'Path'
),
'type'
=>
'text'
,
'required'
=>
true
,
),
'artifact'
=>
array
(
'name'
=>
pht
(
'File Artifact'
),
'type'
=>
'text'
,
'required'
=>
true
,
),
);
}
}
Event Timeline
Log In to Comment