Bug 22440: Add standard accessors for later usage

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 4b470e43a2)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Tomas Cohen Arazi 2023-03-30 10:54:51 +02:00 committed by Martin Renvoize
parent 02f7c41ee9
commit bc849ce820
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
3 changed files with 99 additions and 11 deletions

View File

@ -192,6 +192,21 @@ sub illcomments {
);
}
=head3 comments
my $ill_comments = $req->comments;
Returns a I<Koha::Illcomments> resultset for the linked comments.
=cut
sub comments {
my ( $self ) = @_;
return Koha::Illcomments->_new_from_dbic(
scalar $self->_result->comments
);
}
=head3 logs
=cut
@ -204,12 +219,45 @@ sub logs {
=head3 patron
my $patron = $request->patron;
Returns the linked I<Koha::Patron> object.
=cut
sub patron {
my ( $self ) = @_;
return Koha::Patron->_new_from_dbic(
scalar $self->_result->borrowernumber
return Koha::Patron->_new_from_dbic( scalar $self->_result->patron );
}
=head3 library
my $library = $request->library;
Returns the linked I<Koha::Library> object.
=cut
sub library {
my ($self) = @_;
return Koha::Library->_new_from_dbic( scalar $self->_result->library );
}
=head3 ill_extended_attributes
my $ill_extended_attributes = $request->ill_extended_attributes;
Returns the linked I<Koha::Illrequestattributes> resultset object.
=cut
sub ill_extended_attributes {
my ( $self ) = @_;
return Koha::Illrequestattributes->_new_from_dbic(
scalar $self->_result->ill_extended_attributes
);
}
@ -1142,12 +1190,9 @@ or undef if none exists
sub biblio {
my ( $self ) = @_;
return if !$self->biblio_id;
return Koha::Biblios->find({
biblionumber => $self->biblio_id
});
my $biblio_rs = $self->_result->biblio;
return unless $biblio_rs;
return Koha::Biblio->_new_from_dbic($biblio_rs);
}
=head3 check_out

View File

@ -31,8 +31,6 @@ Koha::Illrequestattribute - Koha Illrequestattribute Object class
=head2 Internal methods
=cut
=head3 _type
=cut
@ -41,6 +39,20 @@ sub _type {
return 'Illrequestattribute';
}
=head3 to_api_mapping
This method returns the mapping for representing a Koha::Illrequestattribute object
on the API.
=cut
sub to_api_mapping {
return {
illrequest_id => 'ill_request_id',
readonly => 'read_only',
};
}
=head1 AUTHOR
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>

View File

@ -334,6 +334,37 @@ __PACKAGE__->belongs_to(
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-06-23 18:44:13
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:on9OCRON/U0uR+m9aPIKPg
__PACKAGE__->has_many(
"comments",
"Koha::Schema::Result::Illcomment",
{ "foreign.illrequest_id" => "self.illrequest_id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->has_many(
"ill_extended_attributes",
"Koha::Schema::Result::Illrequestattribute",
{ "foreign.illrequest_id" => "self.illrequest_id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
__PACKAGE__->belongs_to(
"library",
"Koha::Schema::Result::Branch",
{ branchcode => "branchcode" },
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
);
__PACKAGE__->belongs_to(
"patron",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "borrowernumber" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "CASCADE",
on_update => "CASCADE",
},
);
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;