Habari\Posts::vocabulary_params PHP Метод

vocabulary_params() приватный статический Метод

Accepts a set of term query qualifiers and converts it into a multi-dimensional array of vocabulary (ie: tags), matching method (any, all, not), matching field (id, term, term_display), and list of terms
private static vocabulary_params ( array $params ) : array
$params array An array of parameters provided to Posts::get() as a vocabulary criteria
Результат array An array of parsed term-matching conditions
    private static function vocabulary_params($params)
    {
        $return = array();
        foreach ($params as $key => $value) {
            // split vocab off the beginning of the key
            if (strpos($key, ':') !== false) {
                list($newkey, $subkey) = explode(':', $key, 2);
                $params[$newkey][$subkey] = $value;
                unset($params[$key]);
            }
        }
        foreach ($params as $vocab => $values) {
            foreach ($values as $key => $value) {
                $value = Utils::single_array($value);
                // if there's a colon we've got a mode and a field
                if (strpos($key, ':') !== false) {
                    list($mode, $by_field) = explode(':', $key, 2);
                    foreach ($value as $v) {
                        $return[$mode][$vocab][$by_field][] = $v;
                    }
                } else {
                    // if there's no colon we've got a single field name
                    foreach ($value as $v) {
                        if ($v instanceof Term) {
                            // $vocab is not a vocab, but the mode - always match by its ID for the best performance
                            $return[$vocab][$v->vocabulary->name]['id'][] = $v->id;
                        } else {
                            $return['any'][$vocab][$key][] = $v;
                        }
                    }
                }
            }
        }
        return $return;
    }