当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorProject::setName方法代码示例

本文整理汇总了PHP中PhabricatorProject::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorProject::setName方法的具体用法?PHP PhabricatorProject::setName怎么用?PHP PhabricatorProject::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorProject的用法示例。


在下文中一共展示了PhabricatorProject::setName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $project = new PhabricatorProject();
     $project->setAuthorPHID($user->getPHID());
     $profile = new PhabricatorProjectProfile();
     $e_name = true;
     $errors = array();
     if ($request->isFormPost()) {
         $project->setName($request->getStr('name'));
         $project->setStatus(PhabricatorProjectStatus::ONGOING);
         $profile->setBlurb($request->getStr('blurb'));
         if (!strlen($project->getName())) {
             $e_name = 'Required';
             $errors[] = 'Project name is required.';
         } else {
             $e_name = null;
         }
         if (!$errors) {
             $project->save();
             $profile->setProjectPHID($project->getPHID());
             $profile->save();
             id(new PhabricatorProjectAffiliation())->setUserPHID($user->getPHID())->setProjectPHID($project->getPHID())->setRole('Owner')->setIsOwner(true)->save();
             if ($request->isAjax()) {
                 return id(new AphrontAjaxResponse())->setContent(array('phid' => $project->getPHID(), 'name' => $project->getName()));
             } else {
                 return id(new AphrontRedirectResponse())->setURI('/project/view/' . $project->getID() . '/');
             }
         }
     }
     $error_view = null;
     if ($errors) {
         $error_view = new AphrontErrorView();
         $error_view->setTitle('Form Errors');
         $error_view->setErrors($errors);
     }
     if ($request->isAjax()) {
         $form = new AphrontFormLayoutView();
     } else {
         $form = new AphrontFormView();
         $form->setUser($user);
     }
     $form->appendChild(id(new AphrontFormTextControl())->setLabel('Name')->setName('name')->setValue($project->getName())->setError($e_name))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Blurb')->setName('blurb')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)->setValue($profile->getBlurb()));
     if ($request->isAjax()) {
         if ($error_view) {
             $error_view->setWidth(AphrontErrorView::WIDTH_DIALOG);
         }
         $dialog = id(new AphrontDialogView())->setUser($user)->setWidth(AphrontDialogView::WIDTH_FORM)->setTitle('Create a New Project')->appendChild($error_view)->appendChild($form)->addSubmitButton('Create Project')->addCancelButton('/project/');
         return id(new AphrontDialogResponse())->setDialog($dialog);
     } else {
         $form->appendChild(id(new AphrontFormSubmitControl())->setValue('Create')->addCancelButton('/project/'));
         $panel = new AphrontPanelView();
         $panel->setWidth(AphrontPanelView::WIDTH_FORM)->setHeader('Create a New Project')->appendChild($form);
         return $this->buildStandardPageResponse(array($error_view, $panel), array('title' => 'Create new Project'));
     }
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:57,代码来源:PhabricatorProjectCreateController.php

示例2: applyTransactionEffect

 private function applyTransactionEffect(PhabricatorProject $project, PhabricatorProjectTransaction $xaction)
 {
     $type = $xaction->getTransactionType();
     switch ($type) {
         case PhabricatorProjectTransactionType::TYPE_NAME:
             $project->setName($xaction->getNewValue());
             $project->setPhrictionSlug($xaction->getNewValue());
             $this->validateName($project);
             break;
         case PhabricatorProjectTransactionType::TYPE_STATUS:
             $project->setStatus($xaction->getNewValue());
             break;
         case PhabricatorProjectTransactionType::TYPE_MEMBERS:
             $old = array_fill_keys($xaction->getOldValue(), true);
             $new = array_fill_keys($xaction->getNewValue(), true);
             $add = array();
             $rem = array();
             foreach ($project->getAffiliations() as $affil) {
                 if (empty($new[$affil->getUserPHID()])) {
                     $rem[] = $affil;
                 }
             }
             foreach ($new as $phid => $ignored) {
                 if (empty($old[$phid])) {
                     $affil = new PhabricatorProjectAffiliation();
                     $affil->setRole('');
                     $affil->setUserPHID($phid);
                     $add[] = $affil;
                 }
             }
             $this->addAffiliations = $add;
             $this->remAffiliations = $rem;
             break;
         default:
             throw new Exception("Unknown transaction type '{$type}'!");
     }
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:37,代码来源:PhabricatorProjectEditor.php

示例3: applyTransactionEffect

 private function applyTransactionEffect(PhabricatorProject $project, PhabricatorProjectTransaction $xaction)
 {
     $type = $xaction->getTransactionType();
     switch ($type) {
         case PhabricatorProjectTransactionType::TYPE_NAME:
             $project->setName($xaction->getNewValue());
             $project->setPhrictionSlug($xaction->getNewValue());
             $this->validateName($project);
             break;
         case PhabricatorProjectTransactionType::TYPE_STATUS:
             $project->setStatus($xaction->getNewValue());
             break;
         case PhabricatorProjectTransactionType::TYPE_MEMBERS:
             $old = array_fill_keys($xaction->getOldValue(), true);
             $new = array_fill_keys($xaction->getNewValue(), true);
             $this->addEdges = array_keys(array_diff_key($new, $old));
             $this->remEdges = array_keys(array_diff_key($old, $new));
             break;
         case PhabricatorProjectTransactionType::TYPE_CAN_VIEW:
             $project->setViewPolicy($xaction->getNewValue());
             break;
         case PhabricatorProjectTransactionType::TYPE_CAN_EDIT:
             $project->setEditPolicy($xaction->getNewValue());
             // You can't edit away your ability to edit the project.
             PhabricatorPolicyFilter::mustRetainCapability($this->user, $project, PhabricatorPolicyCapability::CAN_EDIT);
             break;
         case PhabricatorProjectTransactionType::TYPE_CAN_JOIN:
             $project->setJoinPolicy($xaction->getNewValue());
             break;
         default:
             throw new Exception("Unknown transaction type '{$type}'!");
     }
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:33,代码来源:PhabricatorProjectEditor.php

示例4: createProject

 private function createProject()
 {
     $project = new PhabricatorProject();
     $project->setName('Test Project ' . mt_rand());
     return $project;
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:6,代码来源:PhabricatorProjectEditorTestCase.php


注:本文中的PhabricatorProject::setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。