}
+sub logger {
+ my $self = shift;
+ if ($self->{options}->{logger}) {
+ return $self->{options}->{logger};
+ }
+ # return dummy object
+ return {
+ append => sub {},
+ debug => sub {},
+ error => sub {},
+ fatal => sub {},
+ info => sub {},
+ is_level => sub {},
+ warn => sub {},
+ };
+}
1;
$dbh->disconnect();
return undef;
}
+
+ my $root = $self->build_comment_tree($comments);
return $comments;
}
sub build_comment_tree {
- my ($self, $comments, $logger) = @_;
+ my ($self, $comments) = @_;
my $root = [];
my $comment_of = {};
if ($parent) {
push @{$parent->{children}}, $comment;
} else {
- if ($logger) {
- $logger->warn("(Controller::Story) invalid comment order. cid: $cid, pid: $pid");
- }
+ warn("(Controller::Story) invalid comment order. cid: $cid, pid: $pid");
}
}
return $root;
$app->secrets([$app->config->{System}->{secret_key},]);
# add Model
- my $db_opts = $app->config->{Database};
- $app->helper(model => Newslash::Model->loader($db_opts));
+ my $model_opts = $app->config->{Database};
+ $model_opts->{logger} = $app->log;
+ $app->helper(model => Newslash::Model->loader($model_opts));
# use Template::Toolkit 2 render
$app->plugin('Newslash::Plugin::TT2Renderer');