Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121796601
PublishFragmentBuildStepImplementation.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
Sun, Jul 13, 23:40
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Jul 15, 23:40 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27381097
Attached To
rPH Phabricator
PublishFragmentBuildStepImplementation.php
View Options
<?php
final
class
PublishFragmentBuildStepImplementation
extends
BuildStepImplementation
{
public
function
getName
()
{
return
pht
(
'Publish Fragment'
);
}
public
function
getGenericDescription
()
{
return
pht
(
'Publish a fragment based on a file artifact.'
);
}
public
function
getDescription
()
{
$settings
=
$this
->
getSettings
();
return
pht
(
'Publish file artifact
\'
%s
\'
to the fragment path
\'
%s
\'
.'
,
$settings
[
'artifact'
],
$settings
[
'path'
]);
}
public
function
execute
(
HarbormasterBuild
$build
,
HarbormasterBuildTarget
$build_target
)
{
$settings
=
$this
->
getSettings
();
$variables
=
$build_target
->
getVariables
();
$path
=
$this
->
mergeVariables
(
'vsprintf'
,
$settings
[
'path'
],
$variables
);
$artifact
=
$build
->
loadArtifact
(
$settings
[
'artifact'
]);
$file
=
$artifact
->
loadPhabricatorFile
();
$fragment
=
id
(
new
PhragmentFragmentQuery
())
->
setViewer
(
PhabricatorUser
::
getOmnipotentUser
())
->
withPaths
(
array
(
$path
))
->
executeOne
();
if
(
$fragment
===
null
)
{
PhragmentFragment
::
createFromFile
(
PhabricatorUser
::
getOmnipotentUser
(),
$file
,
$path
,
PhabricatorPolicies
::
getMostOpenPolicy
(),
PhabricatorPolicies
::
POLICY_USER
);
}
else
{
if
(
$file
->
getMimeType
()
===
"application/zip"
)
{
$fragment
->
updateFromZIP
(
PhabricatorUser
::
getOmnipotentUser
(),
$file
);
}
else
{
$fragment
->
updateFromFile
(
PhabricatorUser
::
getOmnipotentUser
(),
$file
);
}
}
}
public
function
getArtifactInputs
()
{
return
array
(
array
(
'name'
=>
pht
(
'Publishes File'
),
'key'
=>
$this
->
getSetting
(
'artifact'
),
'type'
=>
HarbormasterBuildArtifact
::
TYPE_FILE
,
),
);
}
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