Lines 39-44
use Koha::Authority;
Link Here
|
39 |
use Koha::Database; |
39 |
use Koha::Database; |
40 |
use Koha::Libraries; |
40 |
use Koha::Libraries; |
41 |
use Koha::RecordProcessor; |
41 |
use Koha::RecordProcessor; |
|
|
42 |
use Koha::Logger; |
43 |
use Koha::Plugins; |
42 |
use Koha::SearchEngine; |
44 |
use Koha::SearchEngine; |
43 |
use Koha::SearchEngine::Indexer; |
45 |
use Koha::SearchEngine::Indexer; |
44 |
use Koha::SearchEngine::Search; |
46 |
use Koha::SearchEngine::Search; |
Lines 673-678
sub AddAuthority {
Link Here
|
673 |
$p->process($record); |
675 |
$p->process($record); |
674 |
} |
676 |
} |
675 |
|
677 |
|
|
|
678 |
# Call before hook |
679 |
_before_authority_action_hooks( { action => 'save', authority_id => $authid, record => $record } ); |
680 |
|
676 |
# Save record into auth_header, update 001 |
681 |
# Save record into auth_header, update 001 |
677 |
my $action; |
682 |
my $action; |
678 |
my $authority; |
683 |
my $authority; |
Lines 1885-1890
sub compare_fields {
Link Here
|
1885 |
return 1; |
1890 |
return 1; |
1886 |
} |
1891 |
} |
1887 |
|
1892 |
|
|
|
1893 |
=head2 _before_authority_action_hooks |
1894 |
|
1895 |
Helper method that takes care of calling all plugin hooks before an authority action |
1896 |
|
1897 |
=cut |
1898 |
|
1899 |
sub _before_authority_action_hooks { |
1900 |
my ($args) = @_; |
1901 |
|
1902 |
my $authority_id = $args->{authority_id}; |
1903 |
my $record = $args->{record}; |
1904 |
my $action = $args->{action} // q{}; |
1905 |
|
1906 |
Koha::Plugins->call( |
1907 |
'before_authority_action', |
1908 |
{ action => $action, payload => { authority_id => $authority_id, record => $record } } |
1909 |
); |
1910 |
} |
1911 |
|
1888 |
=head2 _after_authority_action_hooks |
1912 |
=head2 _after_authority_action_hooks |
1889 |
|
1913 |
|
1890 |
Helper method that takes care of calling all plugin hooks |
1914 |
Helper method that takes care of calling all plugin hooks |
Lines 1892-1902
Helper method that takes care of calling all plugin hooks
Link Here
|
1892 |
=cut |
1916 |
=cut |
1893 |
|
1917 |
|
1894 |
sub _after_authority_action_hooks { |
1918 |
sub _after_authority_action_hooks { |
1895 |
my ($args) = @_; # hash keys: action, authority_id |
1919 |
my ($args) = @_; |
1896 |
return Koha::Plugins->call( 'after_authority_action', $args ); |
1920 |
|
|
|
1921 |
my $authority_id = $args->{authority_id}; |
1922 |
my $action = $args->{action} // q{}; |
1923 |
|
1924 |
my $authority = $action ne 'delete' ? Koha::Authorities->find($authority_id) : undef; |
1925 |
my $record = $authority ? $authority->record : undef; |
1926 |
|
1927 |
Koha::Plugins->call( |
1928 |
'after_authority_action', |
1929 |
{ |
1930 |
action => $action, |
1931 |
payload => { |
1932 |
authority => $authority, |
1933 |
authority_id => $authority_id, |
1934 |
record => $record, |
1935 |
}, |
1936 |
|
1937 |
# NOTE: Deprecated parameters, will be removed in a future release |
1938 |
authority => $authority, |
1939 |
authority_id => $authority_id, |
1940 |
} |
1941 |
); |
1942 |
|
1943 |
# Log deprecation warning if any plugin is still using the old signature |
1944 |
my @plugins = Koha::Plugins->get_enabled_plugins( { verbose => 0 } ); |
1945 |
@plugins = grep { $_->can('after_authority_action') } @plugins; |
1946 |
if (@plugins) { |
1947 |
Koha::Logger->get->warn( |
1948 |
"after_authority_action hook: The old signature (with authority and authority_id as direct parameters) " |
1949 |
. "is deprecated and will be removed in a future release. " |
1950 |
. "Please update your plugin to use the 'payload' parameter instead." ); |
1951 |
} |
1897 |
} |
1952 |
} |
1898 |
|
1953 |
|
1899 |
END { } # module clean-up code here (global destructor) |
1954 |
END { } # module clean-up code here (global destructor) |
1900 |
|
1955 |
|
1901 |
1; |
1956 |
1; |
1902 |
__END__ |
1957 |
__END__ |