/** * Get all or get by search string. */ public function getContacts() { $required = array('type' => true, 'page' => false, 'searchString' => false); $params = $this->controller->getParams($required); if ($params['type'] == 'all') { // $contacts = \ContactsManager::getContactsByUserId($this->controller->identity->getId(), 0, \DialogForm::CONTACTS_PER_PAGE, // isset($params['page']) ? $params['page'] : 1); $contacts = \ContactsManager::getContactsByUserId($this->controller->identity->getId(), \ContactsManager::TYPE_ALL, 50); } else { if ($params['type'] == 'search') { if (!isset($params['searchString'])) { throw new ParamsMissingApiException('SearchStringMissingInSearchTypeRequest'); } $contacts = \ContactsManager::searchContacts($this->controller->identity->getId(), $params['searchString'], \DialogForm::CONTACTS_PER_PAGE, isset($params['page']) ? $params['page'] : 1); } else { throw new InvalidParamsApiException('InvalidType'); } } if (!$contacts) { throw new NotFoundApiException('ContactsNotFound'); } $this->handleContacts($contacts); $this->controller->data = $contacts; }