| 1 | package WWW::Garden::Design::Controller::Garden; | ||
| 2 | |||
| 3 | use Mojo::Base 'Mojolicious::Controller'; | ||
| 4 | |||
| 5 | use Moo; | ||
| 6 | |||
| 7 | our $VERSION = '0.97'; | ||
| 8 | |||
| 9 | # ----------------------------------------------- | ||
| 10 | |||
| 11 | sub process | ||
| 12 | { | ||
| 13 | my($self) = @_; | ||
| 14 | |||
| 15 | $self -> app -> log -> debug('Garden.process()'); | ||
| 16 | |||
| 17 | my($defaults) = $self -> app -> defaults; | ||
| 18 | my($item) = $self -> req -> params -> to_hash; | ||
| 19 | |||
| 20 | $self -> app -> log -> debug("param($_) => $$item{$_}") for sort keys %$item; | ||
| 21 | |||
| 22 | if ($$item{name} && $$item{property_id}) | ||
| 23 | { | ||
| 24 | # In process_garden() all branches print the raw message plus | ||
| 25 | # other information to the log, so nothing is printed here. | ||
| 26 | |||
| 27 | my($packet) = $$defaults{db} -> process_garden($self -> app, $item); | ||
| 28 | |||
| 29 | $self -> stash(json => $packet); | ||
| 30 | } | ||
| 31 | else | ||
| 32 | { | ||
| 33 | my($result) = {garden_id => 0, outcome => 'Error', raw => 'The garden name is mandatory'}; | ||
| 34 | my($packet) = | ||
| 35 | { | ||
| 36 | garden_table => $$defaults{db} -> read_gardens_table, # Warning: Not read_table('gardens'). | ||
| 37 | message => $$defaults{db} -> format_raw_message($result), | ||
| 38 | }; | ||
| 39 | |||
| 40 | $self -> stash(json => $packet); | ||
| 41 | $self -> app -> log -> error($$result{raw}); | ||
| 42 | } | ||
| 43 | |||
| 44 | $self -> render; | ||
| 45 | |||
| 46 | } # End of process. | ||
| 47 | |||
| 48 | # ----------------------------------------------- | ||
| 49 | |||
| 50 | 1; | ||
| 51 | |||
| 52 | =pod | ||
| 53 | |||
| 54 | =head1 NAME | ||
| 55 | |||
| 56 | WWW::Garden::Design::Controller::Garden - Manage the 'flowers' database | ||
| 57 | |||
| 58 | =head1 Machine-Readable Change Log | ||
| 59 | |||
| 60 | The file Changes was converted into Changelog.ini by L<Module::Metadata::Changes>. | ||
| 61 | |||
| 62 | =head1 Version Numbers | ||
| 63 | |||
| 64 | Version numbers < 1.00 represent development versions. From 1.00 up, they are production versions. | ||
| 65 | |||
| 66 | =head1 Repository | ||
| 67 | |||
| 68 | L<https://github.com/ronsavage/WWW-Garden-Design> | ||
| 69 | |||
| 70 | =head1 Support | ||
| 71 | |||
| 72 | Email the author, or log a bug on RT: | ||
| 73 | |||
| 74 | L<https://rt.cpan.org/Public/Dist/Display.html?Name=WWW::Garden::Design>. | ||
| 75 | |||
| 76 | =head1 Author | ||
| 77 | |||
| 78 | L<WWW::Garden::Design> was written by Ron Savage I<E<lt>ron@savage.net.auE<gt>> in 2014. | ||
| 79 | |||
| 80 | My homepage: L<https://savage.net.au/>. | ||
| 81 | |||
| 82 | =head1 Copyright | ||
| 83 | |||
| 84 | Australian copyright (c) 2018, Ron Savage. | ||
| 85 | |||
| 86 | All Programs of mine are 'OSI Certified Open Source Software'; | ||
| 87 | you can redistribute them and/or modify them under the terms of | ||
| 88 | The Perl License, a copy of which is available at: | ||
| 89 | http://dev.perl.org/licenses/ | ||
| 90 | |||
| 91 | =cut |