|
Line 0
Link Here
|
|
|
1 |
package Koha::Status; |
| 2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Koha is free software; you can redistribute it and/or modify it |
| 6 |
# under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# Koha is distributed in the hope that it will be useful, but |
| 11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with Koha; if not, see <https://www.gnu.org/licenses>. |
| 17 |
|
| 18 |
use Modern::Perl; |
| 19 |
|
| 20 |
use Koha; |
| 21 |
|
| 22 |
=head1 NAME |
| 23 |
|
| 24 |
Koha::Status - Koha instance status information |
| 25 |
|
| 26 |
=head1 SYNOPSIS |
| 27 |
|
| 28 |
use Koha::Status; |
| 29 |
|
| 30 |
my $status = Koha::Status->new(); |
| 31 |
my $version_info = $status->version(); |
| 32 |
|
| 33 |
=head1 DESCRIPTION |
| 34 |
|
| 35 |
This class provides methods to retrieve status information about the Koha instance. |
| 36 |
|
| 37 |
=head1 METHODS |
| 38 |
|
| 39 |
=head2 new |
| 40 |
|
| 41 |
my $status = Koha::Status->new(); |
| 42 |
|
| 43 |
Constructor. |
| 44 |
|
| 45 |
=cut |
| 46 |
|
| 47 |
sub new { |
| 48 |
my ($class) = @_; |
| 49 |
return bless {}, $class; |
| 50 |
} |
| 51 |
|
| 52 |
=head2 version |
| 53 |
|
| 54 |
my $version_info = $status->version(); |
| 55 |
|
| 56 |
Returns version information in a structured format similar to |
| 57 |
Koha::Template::Plugin::Koha->Version but with additional metadata. |
| 58 |
|
| 59 |
Returns a hashref with the following structure: |
| 60 |
- version: full version string |
| 61 |
- major: major version number |
| 62 |
- minor: minor version number |
| 63 |
- release: major.minor version |
| 64 |
- maintenance: major.minor.maintenance version |
| 65 |
- development: development version (if applicable) |
| 66 |
|
| 67 |
=cut |
| 68 |
|
| 69 |
sub version { |
| 70 |
my ($self) = @_; |
| 71 |
|
| 72 |
my $version_string = Koha::version(); |
| 73 |
my ( $major, $minor, $maintenance, $development ) = split( '\.', $version_string ); |
| 74 |
|
| 75 |
return { |
| 76 |
version => $version_string, |
| 77 |
major => $major, |
| 78 |
minor => $minor, |
| 79 |
release => $major . "." . $minor, |
| 80 |
maintenance => $major . "." . $minor . "." . $maintenance, |
| 81 |
development => ( $development && $development ne '000' ) ? $development : undef, |
| 82 |
}; |
| 83 |
} |
| 84 |
|
| 85 |
1; |