[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/project/conduit/ -> ProjectCreateConduitAPIMethod.php (source)

   1  <?php
   2  
   3  final class ProjectCreateConduitAPIMethod extends ProjectConduitAPIMethod {
   4  
   5    public function getAPIMethodName() {
   6      return 'project.create';
   7    }
   8  
   9    public function getMethodDescription() {
  10      return pht('Create a project.');
  11    }
  12  
  13    public function defineParamTypes() {
  14      return array(
  15        'name'       => 'required string',
  16        'members'    => 'optional list<phid>',
  17      );
  18    }
  19  
  20    public function defineReturnType() {
  21      return 'dict';
  22    }
  23  
  24    public function defineErrorTypes() {
  25      return array();
  26    }
  27  
  28    protected function execute(ConduitAPIRequest $request) {
  29      $user = $request->getUser();
  30  
  31      $this->requireApplicationCapability(
  32        ProjectCreateProjectsCapability::CAPABILITY,
  33        $user);
  34  
  35      $project = PhabricatorProject::initializeNewProject($user);
  36      $type_name = PhabricatorProjectTransaction::TYPE_NAME;
  37      $members = $request->getValue('members');
  38      $xactions = array();
  39  
  40      $xactions[] = id(new PhabricatorProjectTransaction())
  41        ->setTransactionType($type_name)
  42        ->setNewValue($request->getValue('name'));
  43  
  44      $xactions[] = id(new PhabricatorProjectTransaction())
  45        ->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
  46        ->setMetadataValue('edge:type', PhabricatorEdgeConfig::TYPE_PROJ_MEMBER)
  47        ->setNewValue(
  48          array(
  49            '+' => array_fuse($members),
  50          ));
  51  
  52      $editor = id(new PhabricatorProjectTransactionEditor())
  53        ->setActor($user)
  54        ->setContinueOnNoEffect(true)
  55        ->setContentSourceFromConduitRequest($request);
  56  
  57      $editor->applyTransactions($project, $xactions);
  58  
  59      return $this->buildProjectInfoDictionary($project);
  60    }
  61  
  62  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1