Differential D20973 Diff 49971 src/applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php
| Show First 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | final class DiffusionBranchQueryConduitAPIMethod | ||||
| private function processBranchRefs(ConduitAPIRequest $request, array $refs) { | private function processBranchRefs(ConduitAPIRequest $request, array $refs) { | ||||
| $drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
| $repository = $drequest->getRepository(); | $repository = $drequest->getRepository(); | ||||
| $offset = $request->getValue('offset'); | $offset = $request->getValue('offset'); | ||||
| $limit = $request->getValue('limit'); | $limit = $request->getValue('limit'); | ||||
| foreach ($refs as $key => $ref) { | foreach ($refs as $key => $ref) { | ||||
| if (!$repository->shouldTrackBranch($ref->getShortName())) { | if (!$repository->shouldTrackBranch($ref->getShortName())) { | ||||
| unset($refs[$key]); | unset($refs[$key]); | ||||
artms: This essentially punches holes in array and makes out of it a dictionary with array positions… | |||||
| } | } | ||||
| } | } | ||||
| $with_closed = $request->getValue('closed'); | $with_closed = $request->getValue('closed'); | ||||
| if ($with_closed !== null) { | if ($with_closed !== null) { | ||||
| foreach ($refs as $key => $ref) { | foreach ($refs as $key => $ref) { | ||||
| $fields = $ref->getRawFields(); | $fields = $ref->getRawFields(); | ||||
| if (idx($fields, 'closed') != $with_closed) { | if (idx($fields, 'closed') != $with_closed) { | ||||
| unset($refs[$key]); | unset($refs[$key]); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| // NOTE: We can't apply the offset or limit until here, because we may have | // NOTE: We can't apply the offset or limit until here, because we may have | ||||
| // filtered untrackable branches out of the result set. | // filtered untrackable branches out of the result set. | ||||
| if ($offset) { | if ($offset) { | ||||
| $refs = array_slice($refs, $offset); | $refs = array_slice($refs, $offset); | ||||
| } | } | ||||
| if ($limit) { | if ($limit) { | ||||
| $refs = array_slice($refs, 0, $limit); | $refs = array_slice($refs, 0, $limit); | ||||
| } | } | ||||
| $refs = array_values($refs); | |||||
| return mpull($refs, 'toDictionary'); | return mpull($refs, 'toDictionary'); | ||||
| } | } | ||||
| } | } | ||||
This essentially punches holes in array and makes out of it a dictionary with array positions becoming integer keys in dictionary.