Exemplo n.º 1
0
 /**
  * This method initializes the jiraClient to do two http requests, enrich the objects with eachother and make the project
  * visible as json
  * @Route("/projects", name="Projects")
  * @return encodedObject
  * 
  * @ApiDoc(
  * description="projectAction method",
  * )
  */
 public function projectAction(Request $request)
 {
     $client = $this->initClient();
     //Object array with partialProjects
     $projects = $client->getProjectSummaries();
     foreach ($projects as $p) {
         $id = $p->getId();
         $url = $p->getSelf();
         //initialize a new http request to get project details
         $projectDetails = $client->getProjectDetails($url);
         //initialize a new http request to get project issues
         $projectIssues = $client->getIssues($id);
         //make project objects complete
         ProjectFactory::enrichProject($p, $projectDetails);
         //enrich issue with project
         IssueFactory::enrichProjectWithIssue($p, $projectIssues);
     }
     $encodedObject = $this->jsonEncoder($projects);
     return $encodedObject;
 }
Exemplo n.º 2
0
 /**
  * another HTTP request, this time another url an jqlQuery plus projectId which is given by the controller
  * @param $id
  * @return $sendIssues
  * 
  * @ApiDoc(
  * description="http request for the issues",
  * )
  */
 public function getIssues($id)
 {
     //init curl
     $curl = curl_init();
     //set curl options
     $curlOptions = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_USERPWD => $this->getUsername() . ':' . $this->getPassword(), CURLOPT_URL => $this->getJqlQuery() . $id);
     //build request
     curl_setopt_array($curl, $curlOptions);
     //executerequest
     $output = curl_exec($curl);
     //convert result
     $rawData = json_decode($output, true);
     //send raw data to projectFactory
     $sendIssues = IssueFactory::buildIssueFromArray($rawData);
     return $sendIssues;
 }