Koha::Result::Availability - Base class for availability check results
my $result = Koha::Result::Availability->new();
$result->add_blocker( bad_barcode => $barcode );
$result->add_confirmation( not_issued => $barcode );
$result->add_warning( withdrawn => 1 );
if ( $result->available ) {
# Proceed with action
}
This class provides a standardized structure for availability check results across different operations (check-in, checkout, hold, renewal, etc.).
Results are categorized into: - blockers: Conditions that prevent the action - confirmations: Conditions requiring user confirmation - warnings: Informational messages that don't prevent the action
my $result = Koha::Result::Availability->new();
Constructor. Creates a new result object with empty blockers, confirmations, and warnings.
$result->add_blocker( $key => $value );
Adds a blocker. Blockers prevent the action from proceeding.
$result->add_confirmation( $key => $value );
Adds a confirmation requirement. Confirmations require user acknowledgment before proceeding.
$result->add_warning( $key => $value );
Adds a warning. Warnings are informational and don't prevent the action.
$result->set_context( $key => $value );
Sets a context value. Context provides additional information about the availability check (e.g., related objects like item, checkout, patron).
if ( $result->available ) { ... }
Returns true if there are no blockers, false otherwise.
if ( $result->needs_confirmation ) { ... }
Returns true if there are confirmations required, false otherwise.
my $blockers = $result->blockers;
Returns the blockers hashref.
my $confirmations = $result->confirmations;
Returns the confirmations hashref.
my $warnings = $result->warnings;
Returns the warnings hashref.
my $context = $result->context;
my $item = $result->context->{item};
Returns the context hashref.
Abstract method. Subclasses override to return an arrayref of context keys used for token generation.
How long an as_token confirmation token remains valid for. Confirmation tokens are meant to be round-tripped within a single staff interaction (scan, see the confirmation prompt, confirm), not stored or reused later.
Generates a JWT confirmation token, valid for TOKEN_EXPIRY_SECONDS.
Validates a JWT confirmation token.
my $hashref = $result->to_api;
Returns a hashref suitable for API responses. Includes a confirmation_token when confirmations exist.
my $hashref = $result->to_hashref;
Returns a plain hashref representation of the result, suitable for backward compatibility or serialization.
Koha Development Team <https://koha-community.org/>