/** * Testable search function that does not need globals * * @param string $search * @param string $itemType * @param array $shareTypes * @param int $page * @param int $perPage * @return \OC_OCS_Result */ protected function searchSharees($search, $itemType, array $shareTypes, $page, $perPage) { // Verify arguments if ($itemType === null) { return new \OC_OCS_Result(null, Http::STATUS_BAD_REQUEST, 'Missing itemType'); } // Get users if (in_array(Share::SHARE_TYPE_USER, $shareTypes)) { $this->getUsers($search); } // Get groups if (in_array(Share::SHARE_TYPE_GROUP, $shareTypes)) { $this->getGroups($search); } // Get remote if (in_array(Share::SHARE_TYPE_REMOTE, $shareTypes)) { $this->getRemote($search); } $response = new \OC_OCS_Result($this->result); $response->setItemsPerPage($perPage); if (sizeof($this->reachedEndFor) < 3) { $response->addHeader('Link', $this->getPaginationLink($page, ['search' => $search, 'itemType' => $itemType, 'shareType' => $shareTypes, 'perPage' => $perPage])); } return $response; }
/** * @param string $message */ function buildResponse($shipped, $data, $code, $message = null) { $resp = new \OC_OCS_Result($data, $code, $message); $resp->addHeader('KEY', 'VALUE'); return ['shipped' => $shipped, 'response' => $resp, 'app' => $this->getUniqueID('testapp_')]; }