API::listSearchOptions PHP Method

listSearchOptions() protected method

List the searchoptions of provided itemtype. To use with searchItems function
protected listSearchOptions ( $itemtype, $params = [] ) : array
$itemtype string itemtype (class) of object
$params array
return array all searchoptions of specified itemtype
    protected function listSearchOptions($itemtype, $params = array())
    {
        $this->initEndpoint();
        $soptions = Search::getOptions($itemtype);
        if (isset($params['raw'])) {
            return $soptions;
        }
        $cleaned_soptions = array();
        foreach ($soptions as $sID => $option) {
            if (is_int($sID)) {
                $available_searchtypes = Search::getActionsFor($itemtype, $sID);
                unset($available_searchtypes['searchopt']);
                $available_searchtypes = array_keys($available_searchtypes);
                $cleaned_soptions[$sID] = array('name' => $option['name'], 'table' => $option['table'], 'field' => $option['field'], 'datatype' => isset($option['datatype']) ? $option['datatype'] : "", 'available_searchtypes' => $available_searchtypes);
                $cleaned_soptions[$sID]['uid'] = $this->getSearchOptionUniqID($itemtype, $option);
            } else {
                $cleaned_soptions[$sID] = $option;
            }
        }
        return $cleaned_soptions;
    }