示例#1
0
 function import()
 {
     $projectId = $_REQUEST['project'];
     $stories = collection(Json::decode($_REQUEST['stories']));
     // Synchronize epics
     $epics = array_unique($stories->select('epic')->toArray());
     $existingEpics = $this->jira->query('project=' . $projectId . ' AND issuetype="Epic"', self::EPIC_NAME);
     $epicKeys = [];
     foreach ($existingEpics as $issue) {
         $epicKeys[$issue->fields->{self::EPIC_NAME}] = $issue->key;
         $foundIndex = array_search($issue->fields->{self::EPIC_NAME}, $epics);
         if ($foundIndex !== false) {
             unset($epics[$foundIndex]);
         }
     }
     foreach ($epics as $epic) {
         $result = $this->jira->post('issue', ["fields" => ["project" => ['id' => $projectId], "issuetype" => ["name" => "Epic"], "summary" => $epic, self::EPIC_NAME => $epic]]);
         $epicKeys[$epic] = $result->key;
     }
     // Create stories
     foreach ($stories as $story) {
         $result = $this->jira->post('issue', ["fields" => ["project" => ['id' => $projectId], "summary" => $story->summary, "issuetype" => ["name" => "Story"], self::EPIC_LINK => $epicKeys[$story->epic], self::POINTS => $story->points]]);
     }
     return new Dump($stories->count() . ' stories created');
 }
示例#2
0
 public function generateContent()
 {
     Bridge::initialize();
     $value = chunk_split(base64_encode(Json::encode($this->createSnapshot())));
     $form = new Form(['legend' => 'Compare snapshot', 'fields' => ['direction' => new Input(['name' => 'mode', 'type' => 'select', 'options' => ['as source', 'as target'], 'value' => 'as source']), 'btn' => new Input(['name' => 'compare', 'type' => 'submit', 'class' => 'btn btn-primary', 'value' => 'Compare']), 'snapshot' => new Input(['name' => 'snapshot', 'type' => 'textarea', 'rows' => 30, 'class' => 'form-control', 'style' => 'font-family: monospace;', 'value' => $value])]]);
     $data = $form->import();
     if ($form->isSent() === false) {
         return $form;
     }
     $newValues = $this->createSnapshot();
     $newSnapshot = chunk_split(base64_encode(Json::encode($newValues)));
     if ($data['snapshot'] === $newSnapshot) {
         return new Dialog('No changes detected', 'No changes detected in the <b>wp_options</b> table.');
     }
     $oldValues = Json::decode(base64_decode($data['snapshot']), true);
     if ($data['direction'] === 'as target') {
         $diff = $this->compare($newValues, $oldValues);
     } else {
         $diff = $this->compare($oldValues, $newValues);
     }
     return new Template('sledgehammer/wordpress/templates/diff.php', $diff);
 }
示例#3
0
                <th width="12%">Option changed</th>
                <th width="44%" style="min-width: 250px">New Value</th>
                <th width="44%">Diff</th>
            </tr>
            </thead>
            <tbody>
            <?php 
    foreach ($changes as $key => $change) {
        ?>
                <tr>
                    <td style="white-space: nowrap"><?php 
        echo Html::escape($key);
        ?>
</td>
                    <td style="max-width: 44vw"><?php 
        $value = Json::decode($values[$key], true);
        ob_start();
        dump($value);
        $html = ob_get_clean();
        echo substr($html, strpos($html, '</div>') + 6);
        ?>
</td>
                    <td style="max-width: 44vw"><?php 
        render($change);
        ?>
</td>
                </tr>
            <?php 
    }
    ?>
            </tbody>
示例#4
0
 /**
  * Perform the Api call
  *
  * @param type $options
  * @return type
  * @throws Exception
  */
 function api($options = [])
 {
     $start = microtime(true);
     $options[CURLOPT_USERNAME] = $this->username;
     $options[CURLOPT_PASSWORD] = $this->password;
     $options[CURLOPT_FAILONERROR] = false;
     $options[CURLOPT_RETURNTRANSFER] = true;
     $options += Curl::$defaults;
     $response = new Curl($options);
     $body = $response->getBody();
     $this->logger->append($options[CURLOPT_URL], ['relativeUrl' => substr($options[CURLOPT_URL], strlen($this->baseUrl)), 'duration' => microtime(true) - $start]);
     if (in_array($response->http_code, [200, 201])) {
         return Json::decode($body);
     }
     if (substr($body, 0, 1) === '{') {
         // looks like json?
         $json = json_decode($body);
         if (is_object($json) && isset($json->errorMessages) && count($json->errorMessages) > 0) {
             throw new Exception('[Jira] ' . $json->errorMessages[0]);
         }
         if (is_object($json) && isset($json->errors) && is_object($json->errors)) {
             throw new Exception('[Jira] ' . current(get_object_vars($json->errors)));
         }
     }
     throw new Exception('[Jira] ' . $response->http_code . ' ' . $options[CURLOPT_URL]);
 }