Bug 22834: Add Koha::Plugins::Base->bundle_path
authorTomas Cohen Arazi <tomascohen@theke.io>
Thu, 2 May 2019 18:51:30 +0000 (15:51 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 18 Jun 2019 16:33:53 +0000 (17:33 +0100)
This patch adds a 'bundle_path' method that return the base path for
assets included in the plugin. The idea is that it will be used for
calculation of the absolute path in the filesystem for static content.

To test:
- Apply the unit tests patch
- Run:
  $ kshell
 k$ prove t/db_dependent/Plugins.t
=> FAIL: The method is not implemented
- Apply this patch
- Run:
 k$ prove t/db_dependent/Plugins.t
=> SUCCESS: Tests pass!
- Sign off :-D

Signed-off-by: Arthur Suzuki <arthur.suzuki@biblibre.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Plugins/Base.pm

index b311a77..04fd485 100644 (file)
@@ -69,6 +69,8 @@ sub new {
         $self->store_data({ '__INSTALLED_VERSION__' => $plugin_version });
     }
 
+    $self->{_bundle_path} = abs_path($self->mbf_dir);
+
     return $self;
 }
 
@@ -210,6 +212,20 @@ sub output_html {
     output_with_http_headers( $self->{cgi}, undef, $data, 'html', $status, $extra_options );
 }
 
+=head2 bundle_path
+
+    my $bundle_path = $self->bundle_path
+
+Returns the directory in which bundled files are.
+
+=cut
+
+sub bundle_path {
+    my ($self) = @_;
+
+    return $self->{_bundle_path};
+}
+
 =head2 output
 
    $self->output( $data, $content_type[, $status[, $extra_options]]);