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


PHP Project::save方法代码示例

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


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

示例1: runAddProject

 /**
  * Add a project (AJAX call)
  *
  * @param framework\Request $request The request object
  */
 public function runAddProject(framework\Request $request)
 {
     $i18n = framework\Context::getI18n();
     if (!framework\Context::getScope()->hasProjectsAvailable()) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array("error" => $i18n->__("There are no more projects available in this instance")));
     }
     if ($this->access_level == framework\Settings::ACCESS_FULL) {
         if (($p_name = $request['p_name']) && trim($p_name) != '') {
             try {
                 $project = new entities\Project();
                 $project->setName($p_name);
                 $project->setWorkflowSchemeID($request['workflow_scheme_id']);
                 $project->setIssuetypeSchemeID($request['issuetype_scheme_id']);
                 $project->save();
                 return $this->renderJSON(array('message' => $i18n->__('The project has been added'), 'content' => $this->getComponentHTML('projectbox', array('project' => $project, 'access_level' => $this->access_level)), 'total_count' => entities\Project::getProjectsCount(), 'more_available' => framework\Context::getScope()->hasProjectsAvailable()));
             } catch (\InvalidArgumentException $e) {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array("error" => $i18n->__('A project with the same key already exists')));
             } catch (\Exception $e) {
                 $this->getResponse()->setHttpStatus(400);
                 return $this->renderJSON(array("error" => $i18n->__('An error occurred: ' . $e->getMessage())));
             }
         }
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array("error" => $i18n->__('Please specify a valid project name')));
     }
     $this->getResponse()->setHttpStatus(400);
     return $this->renderJSON(array("error" => $i18n->__("You don't have access to add projects")));
 }
开发者ID:nrensen,项目名称:thebuggenie,代码行数:35,代码来源:Main.php

示例2: runDoImportCSV


//.........这里部分代码省略.........
             foreach ($errors as $error) {
                 $errordiv .= '<li>' . $error . '</li>';
             }
             $errordiv .= '</ul>';
             $this->getResponse()->setHttpStatus(400);
             return $this->renderJSON(array('errordetail' => $errordiv, 'error' => $this->getI18n()->__('Errors occured while importing, see the error list in the import screen for further details')));
         }
     } catch (\Exception $e) {
         $this->getResponse()->setHttpStatus(400);
         return $this->renderJSON(array('errordetail' => $e->getMessage(), 'error' => $e->getMessage()));
     }
     if ($request['csv_dry_run']) {
         return $this->renderJSON(array('message' => $this->getI18n()->__('Dry-run successful, you can now uncheck the dry-run box and import your data.')));
     } else {
         switch ($request['type']) {
             case self::CSV_TYPE_CLIENTS:
                 for ($i = 0; $i != count($data); $i++) {
                     try {
                         $activerow = $data[$i];
                         $client = new entities\Client();
                         $client->setName($activerow[self::CSV_CLIENT_NAME]);
                         if (isset($activerow[self::CSV_CLIENT_EMAIL])) {
                             $client->setEmail($activerow[self::CSV_CLIENT_EMAIL]);
                         }
                         if (isset($activerow[self::CSV_CLIENT_WEBSITE])) {
                             $client->setWebsite($activerow[self::CSV_CLIENT_WEBSITE]);
                         }
                         if (isset($activerow[self::CSV_CLIENT_FAX])) {
                             $client->setFax($activerow[self::CSV_CLIENT_FAX]);
                         }
                         if (isset($activerow[self::CSV_CLIENT_TELEPHONE])) {
                             $client->setTelephone($activerow[self::CSV_CLIENT_TELEPHONE]);
                         }
                         $client->save();
                     } catch (\Exception $e) {
                         $errors[] = $this->getI18n()->__('Row %row failed: %err', array('%row' => $i + 1, '%err' => $e->getMessage()));
                     }
                 }
                 break;
             case self::CSV_TYPE_PROJECTS:
                 for ($i = 0; $i != count($data); $i++) {
                     try {
                         $activerow = $data[$i];
                         $project = new entities\Project();
                         $project->setName($activerow[self::CSV_PROJECT_NAME]);
                         $project->save();
                         if (isset($activerow[self::CSV_PROJECT_PREFIX])) {
                             $project->setPrefix($activerow[self::CSV_PROJECT_PREFIX]);
                             $project->setUsePrefix(true);
                         }
                         if (isset($activerow[self::CSV_PROJECT_SCRUM])) {
                             if ($activerow[self::CSV_PROJECT_SCRUM] == '1') {
                                 $project->setUsesScrum(true);
                             }
                         }
                         if (isset($activerow[self::CSV_PROJECT_OWNER]) && isset($activerow[self::CSV_PROJECT_OWNER_TYPE])) {
                             switch ($activerow[self::CSV_PROJECT_OWNER_TYPE]) {
                                 case self::CSV_IDENTIFIER_TYPE_USER:
                                     $user = new entities\User($activerow[self::CSV_PROJECT_OWNER]);
                                     $project->setOwner($user);
                                     break;
                                 case self::CSV_IDENTIFIER_TYPE_TEAM:
                                     $team = new entities\Team($activerow[self::CSV_PROJECT_OWNER]);
                                     $project->setOwner($team);
                                     break;
                             }
开发者ID:pkdevboxy,项目名称:thebuggenie,代码行数:67,代码来源:Main.php


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