Differential D21540 Diff 51272 src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
| Show First 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | /* -( Cursors )------------------------------------------------------------ */ | ||||
| } | } | ||||
| protected function newPagingMapFromPartialObject($object) { | protected function newPagingMapFromPartialObject($object) { | ||||
| return array( | return array( | ||||
| 'id' => (int)$object->getID(), | 'id' => (int)$object->getID(), | ||||
| ); | ); | ||||
| } | } | ||||
| final private function getExternalCursorStringForResult($object) { | private function getExternalCursorStringForResult($object) { | ||||
| $cursor = $this->newExternalCursorStringForResult($object); | $cursor = $this->newExternalCursorStringForResult($object); | ||||
| if (!is_string($cursor)) { | if (!is_string($cursor)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'Expected "newExternalCursorStringForResult()" in class "%s" to '. | 'Expected "newExternalCursorStringForResult()" in class "%s" to '. | ||||
| 'return a string, but got "%s".', | 'return a string, but got "%s".', | ||||
| get_class($this), | get_class($this), | ||||
| phutil_describe_type($cursor))); | phutil_describe_type($cursor))); | ||||
| } | } | ||||
| return $cursor; | return $cursor; | ||||
| } | } | ||||
| final protected function getExternalCursorString() { | final protected function getExternalCursorString() { | ||||
| return $this->externalCursorString; | return $this->externalCursorString; | ||||
| } | } | ||||
| final private function setExternalCursorString($external_cursor) { | private function setExternalCursorString($external_cursor) { | ||||
| $this->externalCursorString = $external_cursor; | $this->externalCursorString = $external_cursor; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final protected function getIsQueryOrderReversed() { | final protected function getIsQueryOrderReversed() { | ||||
| return $this->isQueryOrderReversed; | return $this->isQueryOrderReversed; | ||||
| } | } | ||||
| final protected function setIsQueryOrderReversed($is_reversed) { | final protected function setIsQueryOrderReversed($is_reversed) { | ||||
| $this->isQueryOrderReversed = $is_reversed; | $this->isQueryOrderReversed = $is_reversed; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final private function getInternalCursorObject() { | private function getInternalCursorObject() { | ||||
| return $this->internalCursorObject; | return $this->internalCursorObject; | ||||
| } | } | ||||
| final private function setInternalCursorObject( | private function setInternalCursorObject( | ||||
| PhabricatorQueryCursor $cursor) { | PhabricatorQueryCursor $cursor) { | ||||
| $this->internalCursorObject = $cursor; | $this->internalCursorObject = $cursor; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| final private function getInternalCursorFromExternalCursor( | private function getInternalCursorFromExternalCursor( | ||||
| $cursor_string) { | $cursor_string) { | ||||
| $cursor_object = $this->newInternalCursorFromExternalCursor($cursor_string); | $cursor_object = $this->newInternalCursorFromExternalCursor($cursor_string); | ||||
| if (!($cursor_object instanceof PhabricatorQueryCursor)) { | if (!($cursor_object instanceof PhabricatorQueryCursor)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'Expected "newInternalCursorFromExternalCursor()" to return an '. | 'Expected "newInternalCursorFromExternalCursor()" to return an '. | ||||
| 'object of class "PhabricatorQueryCursor", but got "%s" (in '. | 'object of class "PhabricatorQueryCursor", but got "%s" (in '. | ||||
| 'class "%s").', | 'class "%s").', | ||||
| phutil_describe_type($cursor_object), | phutil_describe_type($cursor_object), | ||||
| get_class($this))); | get_class($this))); | ||||
| } | } | ||||
| return $cursor_object; | return $cursor_object; | ||||
| } | } | ||||
| final private function getPagingMapFromCursorObject( | private function getPagingMapFromCursorObject( | ||||
| PhabricatorQueryCursor $cursor, | PhabricatorQueryCursor $cursor, | ||||
| array $keys) { | array $keys) { | ||||
| $map = $this->newPagingMapFromCursorObject($cursor, $keys); | $map = $this->newPagingMapFromCursorObject($cursor, $keys); | ||||
| if (!is_array($map)) { | if (!is_array($map)) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| ▲ Show 20 Lines • Show All 3,055 Lines • Show Last 20 Lines | |||||