/**
  * @param int $issueId
  * @param $gerritNumber
  * @param array $expectedStatus
  */
 protected function getTicketStatus($issueId, $gerritNumber, $expectedStatus = array())
 {
     //		$this->redmineClient = new Redmine\Client(
     //			$this->settings['Redmine']['url'],
     //			$this->settings['Redmine']['apiKey']
     //		);
     //		$res = $this->redmineClient->api('issue')->show($issueId);
     //		if (is_array($res)) {
     //			if(in_array($res['issue']['status']['name'], $unexpectedStatus)) {
     //				GeneralUtility::writeLine('|Issue #'.$issueId.'|'.$res['issue']['subject'].'|https://review.typo3.org/#/c/'.$gerritNumber.'/|', 'yellow');
     //			}
     //		} else {
     //			$this->counter['noArray']++;
     //		}
     try {
         $search = $this->connection->getIndex()->getType('issue');
         $doc = $search->getDocument($issueId)->getData();
         //			\TYPO3\Flow\var_dump($doc);
         if (!in_array($doc['status']['name'], $expectedStatus)) {
             /**
              * Check if another patchset exists
              */
             $hasPatchset = false;
             $numberOfPatchsets = 0;
             foreach ($doc['journals'] as $journalEntry) {
                 if (isset($journalEntry['notes']) && strstr($journalEntry['notes'], 'It is available at http://review.typo3.org/') && !strstr($journalEntry['notes'], 'It is available at http://review.typo3.org/' . $gerritNumber)) {
                     $hasPatchset = true;
                     //						GeneralUtility::writeLine($journalEntry['notes'], 'green');
                 }
                 if (isset($journalEntry['notes']) && !strstr($journalEntry['notes'], 'It is available at http://review.typo3.org/' . $gerritNumber)) {
                     $numberOfPatchsets++;
                 }
             }
             if (!$hasPatchset && $numberOfPatchsets > 1) {
                 GeneralUtility::writeLine('|Issue #' . $issueId . '|' . $doc['subject'] . '|https://review.typo3.org/#/c/' . $gerritNumber . '/|', 'yellow');
             }
         } else {
             //				GeneralUtility::writeLine($issueId . ' has correct status ', 'green', false);
             //				GeneralUtility::writeLine($doc['status']['name'], 'yellow');
         }
     } catch (El\Exception\NotFoundException $e) {
         #GeneralUtility::writeLine($e->getMessage(), 'inverseRed');
     }
 }
 /**
  * @param $fileName
  * @return string
  */
 protected function getExtensionNameFromFileName($fileName)
 {
     foreach ($this->whiteList as $topic => $paths) {
         foreach ($paths as $path) {
             $pattern = '/' . str_replace('/', '\\/', $path) . '/';
             preg_match($pattern, $fileName, $matches);
             if (isset($matches[1])) {
                 #GeneralUtility::writeLine('ALLOWED: ' . $topic . ' | ' . $path . ' matches file ' . $fileName, 'green');
                 return $topic;
             }
         }
     }
     foreach ($this->blackList as $topic => $paths) {
         foreach ($paths as $path) {
             $pattern = '/' . str_replace('/', '\\/', $path) . '/';
             preg_match($pattern, $fileName, $matches);
             if (isset($matches[1])) {
                 #GeneralUtility::writeLine('DISALLOWED: ' . $topic . ' | ' . $path . ' matches file ' . $fileName, 'red');
                 return false;
             }
         }
     }
     $pattern = '/typo3\\/sysext\\/(.*?)\\//';
     preg_match($pattern, $fileName, $matches);
     if (isset($matches[1])) {
         #GeneralUtility::writeLine('REGULAR hit for '.$matches[1] .' for '.$fileName, 'yellow');
         return 'EXT: ' . $matches[1];
     } else {
         GeneralUtility::writeLine('NOTANEXT ' . $fileName, 'blue');
         return 'NOTANEXT';
     }
 }
 /**
  * @param array $document
  * @param string $type
  * @throws \Exception
  */
 protected function addDocumentToElastic(array $document, $type = 'issue')
 {
     switch ($type) {
         case 'issue':
             if (isset($document['custom_fields'])) {
                 foreach ($document['custom_fields'] as $customField) {
                     switch ($customField['id']) {
                         case 4:
                             $document['typo3_version'] = isset($customField['value']) ? $customField['value'] : '-';
                             break;
                         case 5:
                             $document['php_version'] = isset($customField['value']) ? $customField['value'] : '-';
                             break;
                         case 8:
                             $document['complexity'] = isset($customField['value']) ? $customField['value'] : '-';
                             break;
                         case 15:
                             $document['isregression'] = isset($customField['value']) ? true : false;
                             break;
                         case 18:
                             $document['focus']['name'] = isset($customField['value']) ? $customField['value'] : '-';
                             break;
                         default:
                     }
                 }
             }
             $document['updated_on'] = $this->fixDateFormat($document['updated_on']);
             $document['created_on'] = $this->fixDateFormat($document['created_on']);
             $type = new Elastica\Type($this->elasticIndex, 'issue');
             try {
                 $testIfDocExists = $type->getDocument($document['id']);
             } catch (\Exception $e) {
                 $message = new \WMDB\Forger\Utilities\Slack\Message();
                 $message->sendMessage($document);
             }
             break;
         case 'review':
             $type = new Elastica\Type($this->elasticIndex, 'review');
             break;
         case 'user':
             $type = new Elastica\Type($this->elasticIndex, 'user');
             break;
         default:
     }
     #\TYPO3\Flow\var_dump($type);
     $doc = new Elastica\Document($document['id'], $document);
     #\TYPO3\Flow\var_dump($doc);
     $type->addDocument($doc);
     GeneralUtility::writeLine('+' . $type->getName() . ':' . $document['id'] . ' ', 'green', false);
     #sleep(1);
 }