Bugzilla – Attachment 142137 Details for
Bug 31224
Koha::Biblio::Metadata->record should use the EmbedItems filter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31224: Add Koha::Biblio->metadata_record
Bug-31224-Add-KohaBiblio-metadatarecord.patch (text/plain), 3.16 KB, created by
Martin Renvoize (ashimema)
on 2022-10-19 09:20:27 UTC
(
hide
)
Description:
Bug 31224: Add Koha::Biblio->metadata_record
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-10-19 09:20:27 UTC
Size:
3.16 KB
patch
obsolete
>From 0f0f8e2346d9a1167eac45b7ffb12310173a164d Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 22 Jul 2022 17:42:35 -0300 >Subject: [PATCH] Bug 31224: Add Koha::Biblio->metadata_record > >This patch introduces a higher-level method for retrieving a 'prepared' >record for using in specific contexts. In particular, I only focused on >embedding item information and OPAC view filtering. But we could add a >way to get the record through the ViewPolicy also for staff. > >The virtue of this patch is that it explains better than my words why I >think having the *embed_items* and *opac* parameters in >Koha::Biblio::Metadata->record is not ideal. And makes the other >implementation feel like is done at the wrong level. > >I know it's been done like that to act as a drop-in replacement fro GetMarcBiblio, >which was a good first step. But we need to revisit how it is used, in general, to come >up with a more refined and useful design. So we do not port the same >design problems from C4::* into Koha::*. > >Try to think how it would be used in contexts like opac-MARCdetail.pl or >any other OPAC controller script. > >Thanks! >--- > Koha/Biblio.pm | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 66 insertions(+) > >diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm >index 3c8e5cb4b2..f3025ed706 100644 >--- a/Koha/Biblio.pm >+++ b/Koha/Biblio.pm >@@ -88,6 +88,72 @@ sub metadata { > return Koha::Biblio::Metadata->_new_from_dbic($metadata); > } > >+=head3 metadata_record >+ >+ my $record = $biblio->metadata_record( >+ { >+ [ embed_items => 1|0, >+ opac => 1|0, >+ patron => $patron, >+ expand_coded_fields => 1|0 ] >+ } >+ ); >+ >+Returns the metadata serialized as appropriate for the metadata object >+type. Currently only I<MARC::Record> objects are returned. >+ >+=cut >+ >+sub metadata_record { >+ my ($self, $params) = @_; >+ >+ my $patron = $params->{patron}; >+ >+ my $record = $self->metadata->record; >+ >+ if ( $params->{embed_items} or $params->{opac} ) { >+ # There's need for a RecordProcessor, let's do it! >+ my @filters; >+ my $options = { >+ interface => 'opac', >+ frameworkcode => $self->frameworkcode, >+ }; >+ >+ if ($params->{embed_items}) { >+ push @filters, 'EmbedItems'; >+ if ($params->{opac}) { >+ $options->{items} = $self->items->filter_by_visible_in_opac( >+ { >+ ( $params->{patron} ? patron => $params->{patron} : ()) >+ } >+ ); >+ } >+ else { >+ $options->{items} = $self->items; >+ } >+ } >+ >+ if ( $params->{opac} ) { >+ push @filters, 'ViewPolicy'; >+ } >+ >+ if ( $params->{expand_coded_fields} ) { >+ push @filters, 'ExpandCodedFields'; >+ } >+ >+ my $rp = Koha::RecordProcessor->new( >+ { >+ filters => \@filters, >+ options => $options >+ } >+ ); >+ >+ $rp->process( $record ); >+ } >+ >+ return $record; >+} >+ > =head3 orders > > my $orders = $biblio->orders(); >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31224
:
138060
|
138061
|
138062
|
138063
|
138064
|
142137
|
142138
|
142139
|
142140
|
142141
|
142142
|
142143
|
161933
|
161934
|
161935
|
161936
|
161937
|
161938
|
161939
|
161940
|
161941
|
161942
|
161943
|
161944
|
173530
|
173531
|
173532
|
173533
|
173534
|
173535
|
173588
|
173597
|
173598
|
173636
|
173637
|
173638
|
173639
|
173640
|
173641
|
173642
|
173643
|
173644
|
174262
|
174263