Changeset View
Changeset View
Standalone View
Standalone View
src/applications/doorkeeper/bridge/DoorkeeperBridgeGitHubIssue.php
| Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | foreach ($refs as $ref) { | ||||
| $body = $result->getBody(); | $body = $result->getBody(); | ||||
| $ref->setIsVisible(true); | $ref->setIsVisible(true); | ||||
| $ref->setAttribute('api.raw', $body); | $ref->setAttribute('api.raw', $body); | ||||
| $ref->setAttribute('name', $body['title']); | $ref->setAttribute('name', $body['title']); | ||||
| $obj = $ref->getExternalObject(); | $obj = $ref->getExternalObject(); | ||||
| if ($obj->getID()) { | |||||
| continue; | |||||
| } | |||||
| $this->fillObjectFromData($obj, $result); | $this->fillObjectFromData($obj, $result); | ||||
| $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | ||||
| $obj->save(); | $obj->save(); | ||||
| unset($unguarded); | unset($unguarded); | ||||
| } | } | ||||
| } | } | ||||
| public function fillObjectFromData(DoorkeeperExternalObject $obj, $result) { | public function fillObjectFromData(DoorkeeperExternalObject $obj, $result) { | ||||
| $body = $result->getBody(); | $body = $result->getBody(); | ||||
| $uri = $body['html_url']; | $uri = $body['html_url']; | ||||
| $obj->setObjectURI($uri); | $obj->setObjectURI($uri); | ||||
| $title = idx($body, 'title'); | |||||
| $description = idx($body, 'body'); | |||||
| $created = idx($body, 'created_at'); | |||||
| $created = strtotime($created); | |||||
| $state = idx($body, 'state'); | |||||
| $obj->setProperty('task.title', $title); | |||||
| $obj->setProperty('task.description', $description); | |||||
| $obj->setProperty('task.created', $created); | |||||
| $obj->setProperty('task.state', $state); | |||||
| } | } | ||||
| } | } | ||||