<<

NAME

Koha::REST::Plugin::Query

API

Mojolicious::Plugin methods

register

Helper methods

extract_reserved_params

    my ( $filtered_params, $reserved_params ) = $c->extract_reserved_params($params);

Generates the DBIC query from the query parameters.

dbic_merge_sorting

    $attributes = $c->dbic_merge_sorting({ attributes => $attributes, params => $params });

Generates the DBIC order_by attributes based on $params, and merges into $attributes.

dbic_merge_prefetch

    $attributes = $c->dbic_merge_prefetch({ attributes => $attributes, result_set => $result_set });

Generates the DBIC prefetch attribute based on embedded relations, and merges into $attributes.

dbic_validate_operators

    $attributes = $c->dbic_validate_operators( { filtered_params => $filtered_params } );

Validate operators in the passed query.

_build_query_params_from_api

    my $params = _build_query_params_from_api( $filtered_params, $reserved_params );

Builds the params for searching on DBIC based on the selected matching algorithm. Valid options are contains, starts_with, ends_with and exact. Default is contains. If other value is passed, a Koha::Exceptions::WrongParameter exception is raised.

merge_q_params

    $c->merge_q_params( $filtered_params, $q_params, $result_set );

Merges parameters from $q_params into $filtered_params.

stash_embed

    $c->stash_embed( { spec => $op_spec } );

Unwraps and stashes the x-koha-embed headers for use later query construction

stash_overrides

    # Stash the overrides
    $c->stash_overrides();
    #Use it
    my $overrides = $c->stash('koha.overrides');
    if ( $overrides->{pickup_location} ) { ... }

This helper method parses 'x-koha-override' headers and stashes the passed overriders in the for of a hashref for easy use in controller methods.

FIXME: With the currently used JSON::Validator version we use, it is not possible to use the validated and coerced data (it doesn't validate array-type headers) so this implementation relies on manual parsing. Look at the JSON::Validator changelog for reference: https://metacpan.org/changes/distribution/JSON-Validator#L14

Internal methods

_reserved_words

    my $reserved_words = _reserved_words();

_build_order_atom

    my $order_atom = _build_order_atom( $string );

Parses $string and outputs data valid for using in SQL::Abstract order_by attribute according to the following rules:

     string -> I<string>
    +string -> I<{ -asc => string }>
    -string -> I<{ -desc => string }>

_parse_embed

    my $embed = _parse_embed( $string );

Parses $string and outputs data valid for passing to the Kohaa::Object(s)->to_api method.

_merge_embed

    _merge_embed( $parsed_embed, $global_embed );

Merges the hash referenced by $parsed_embed into $global_embed.

_validate_operator

_validate_query

<<