[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class HarbormasterPublishFragmentBuildStepImplementation 4 extends HarbormasterBuildStepImplementation { 5 6 public function getName() { 7 return pht('Publish Fragment'); 8 } 9 10 public function getGenericDescription() { 11 return pht('Publish a fragment based on a file artifact.'); 12 } 13 14 public function getDescription() { 15 return pht( 16 'Publish file artifact %s as fragment %s.', 17 $this->formatSettingForDescription('artifact'), 18 $this->formatSettingForDescription('path')); 19 } 20 21 public function execute( 22 HarbormasterBuild $build, 23 HarbormasterBuildTarget $build_target) { 24 25 $settings = $this->getSettings(); 26 $variables = $build_target->getVariables(); 27 28 $path = $this->mergeVariables( 29 'vsprintf', 30 $settings['path'], 31 $variables); 32 33 $artifact = $build->loadArtifact($settings['artifact']); 34 35 $file = $artifact->loadPhabricatorFile(); 36 37 $fragment = id(new PhragmentFragmentQuery()) 38 ->setViewer(PhabricatorUser::getOmnipotentUser()) 39 ->withPaths(array($path)) 40 ->executeOne(); 41 42 if ($fragment === null) { 43 PhragmentFragment::createFromFile( 44 PhabricatorUser::getOmnipotentUser(), 45 $file, 46 $path, 47 PhabricatorPolicies::getMostOpenPolicy(), 48 PhabricatorPolicies::POLICY_USER); 49 } else { 50 if ($file->getMimeType() === 'application/zip') { 51 $fragment->updateFromZIP(PhabricatorUser::getOmnipotentUser(), $file); 52 } else { 53 $fragment->updateFromFile(PhabricatorUser::getOmnipotentUser(), $file); 54 } 55 } 56 } 57 58 public function getArtifactInputs() { 59 return array( 60 array( 61 'name' => pht('Publishes File'), 62 'key' => $this->getSetting('artifact'), 63 'type' => HarbormasterBuildArtifact::TYPE_FILE, 64 ), 65 ); 66 } 67 68 public function getFieldSpecifications() { 69 return array( 70 'path' => array( 71 'name' => pht('Path'), 72 'type' => 'text', 73 'required' => true, 74 ), 75 'artifact' => array( 76 'name' => pht('File Artifact'), 77 'type' => 'text', 78 'required' => true, 79 ), 80 ); 81 } 82 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |