Commit | Line | Data |
3259663d |
1 | package CatalystX::HelpText::File; |
fceef83f |
2 | use Moose; |
3259663d |
3 | use MooseX::Types::Moose qw/Str/; |
4 | use Moose::Autobox; |
5 | use Carp qw/confess/; |
6 | use namespace::autoclean; |
7 | |
8 | has help_files_path => ( |
de884840 |
9 | is => 'ro', |
10 | isa => Str, |
11 | default => '/support/help/', |
3259663d |
12 | ); |
13 | |
14 | has help_files_ext => ( |
15 | is => 'ro', |
16 | isa => Str, |
17 | default => '.html', |
18 | ); |
19 | |
20 | sub get_help_text_for { |
21 | my ($self, $c, $help_key) = @_; |
de884840 |
22 | confess('No $c provided') unless $c; |
23 | confess('No $help_key provided') unless $help_key; |
3259663d |
24 | |
25 | my $file_path = $c->path_to('root', $self->help_files_path.$help_key.$self->help_files_ext); |
26 | my $string = ''; |
3259663d |
27 | if ( -e $file_path ) { |
28 | local $/=undef; |
29 | open FILE, $file_path or confess "Couldn't open file: $!"; |
30 | $string = <FILE>; |
31 | close FILE; |
32 | } |
33 | |
34 | return $string; |
35 | } |
36 | |
37 | 1; |
de884840 |
38 | |