Beispiel #1
0
 /**
  * Create an issue of a product.
  * @param  Product $product           - the product which the issue points to
  * @param  String  $productVersion    - the version of the product where the issue found
  * @param  String  $issueCategorySlug - the unique slug of the category of the issue
  * @param  User    $hunter            - the user who found the issue
  * @param  String  $issueTitle        - the title of the issue
  * @param  String  $issueDescription  - the description of the issue
  * @param  boolean $isTokenValid      - whether the CSRF token is correct
  * @return an array with data validation result
  */
 public function createIssue($product, $productVersion, $issueCategorySlug, $hunter, $issueTitle, $issueDescription, $isTokenValid)
 {
     $issueCategory = $this->getIssueCategoryObjectUsingSlug($issueCategorySlug);
     $result = array('isSuccessful' => false, 'isProductExists' => $product != NULL, 'isProductVersionEmpty' => empty($productVersion), 'isProductVersionLegal' => $this->isProductVersionLegal($productVersion), 'isIssueCategoryEmpty' => $issueCategory == NULL, 'isUserLoggedIn' => $hunter != NULL, 'isIssueTitleEmpty' => empty($issueTitle), 'isIssueTitleLegal' => $this->isIssueTitleLegal($issueTitle), 'isDescriptionEmpty' => empty($issueDescription), 'isTokenValid' => $isTokenValid);
     $result['isSuccessful'] = $result['isProductExists'] && !$result['isProductVersionEmpty'] && $result['isProductVersionLegal'] && !$result['isIssueCategoryEmpty'] && $result['isUserLoggedIn'] && !$result['isIssueTitleEmpty'] && $result['isIssueTitleLegal'] && !$result['isDescriptionEmpty'] && $result['isTokenValid'];
     if ($result['isSuccessful']) {
         $issueStatus = IssueStatus::findFirst("issue_status_slug = 'unconfirmed'");
         $issue = new Issue();
         $issue->setProduct($product);
         $issue->setProductVersion($productVersion);
         $issue->setIssueCategory($issueCategory);
         $issue->setIssueStatus($issueStatus);
         $issue->setHunter($hunter);
         $issue->setIssueTitle($issueTitle);
         $issue->setIssueDescription($issueDescription);
         if (!$issue->create()) {
             $result['isSuccessful'] = false;
         } else {
             $result['issueId'] = $issue->getIssueId();
         }
     }
     return $result;
 }
Beispiel #2
0
 /**
  * The setter of the field issue_status_id.
  * @param IssueStatus $issueStatus - the status of the issue
  */
 public function setIssueStatus(IssueStatus $issueStatus)
 {
     if ($issueStatus == NULL) {
         throw new InvalidArgumentException('[Model\\Issue] Invalid Model\\IssueStatus.');
     }
     $this->issue_status_id = $issueStatus->getIssueStatusId();
 }