| 1 | package AxKit::App::TABOO::Data::Plurals::MediaTypes; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use Carp; | ||
| 5 | |||
| 6 | use Data::Dumper; | ||
| 7 | use AxKit::App::TABOO::Data; | ||
| 8 | use AxKit::App::TABOO::Data::MediaType; | ||
| 9 | use AxKit::App::TABOO::Data::Plurals; | ||
| 10 | |||
| 11 | |||
| 12 | use vars qw/@ISA/; | ||
| 13 | @ISA = qw(AxKit::App::TABOO::Data::Plurals); | ||
| 14 | |||
| 15 | use DBI; | ||
| 16 | use Exception::Class::DBI; | ||
| 17 | |||
| 18 | |||
| 19 | our $VERSION = '0.18'; | ||
| 20 | |||
| 21 | AxKit::App::TABOO::Data::Plurals::MediaTypes->dbtable("mediatypes"); | ||
| 22 | AxKit::App::TABOO::Data::Plurals::MediaTypes->dbfrom("mediatypes"); | ||
| 23 | |||
| 24 | |||
| 25 | =head1 NAME | ||
| 26 | |||
| 27 | AxKit::App::TABOO::Data::Plurals::MediaTypes - Data objects to handle multiple MediaTypes in TABOO | ||
| 28 | |||
| 29 | =head1 DESCRIPTION | ||
| 30 | |||
| 31 | Lotsa MIME Types. | ||
| 32 | |||
| 33 | =head2 Methods | ||
| 34 | |||
| 35 | =over | ||
| 36 | |||
| 37 | =item C<new(@dbconnectargs)> | ||
| 38 | |||
| 39 | The constructor. Nothing special. | ||
| 40 | |||
| 41 | =cut | ||
| 42 | |||
| 43 | sub new { | ||
| 44 | my $that = shift; | ||
| 45 | my $class = ref($that) || $that; | ||
| 46 | my $self = { | ||
| 47 | ENTRIES => [], # Internally, some methods finds it useful that the entries are stored in a array of this name. | ||
| 48 | DBCONNECTARGS => \@_, | ||
| 49 | XMLPREFIX => undef, | ||
| 50 | XMLELEMENT => undef, | ||
| 51 | XMLNS => undef, | ||
| 52 | }; | ||
| 53 | bless($self, $class); | ||
| 54 | return $self; | ||
| 55 | } | ||
| 56 | |||
| 57 | |||
| 58 | =item C<load(what =E<gt> fields, limit =E<gt> {key =E<gt> value, [...]}, orderby =E<gt> fields, entries =E<gt> number)> | ||
| 59 | |||
| 60 | This load method can be used to retrieve a number of entries from a | ||
| 61 | data store. It uses named parameters, the first C<what> is used to | ||
| 62 | determine which fields to retrieve. It is a string consisting of a | ||
| 63 | commaseparated list of fields, as specified in the data store. The | ||
| 64 | C<limit> argument is to be used to determine which records to | ||
| 65 | retrieve, these will be combined by logical AND. You may also supply a | ||
| 66 | C<orderby> argument, which is an expression used to determine the | ||
| 67 | order of entries returned. Finally, you may supply a C<entries> | ||
| 68 | argument, which is the maximum number of entries to retrieve. | ||
| 69 | |||
| 70 | It will retrieve the data, and then call C<populate()> for each of the | ||
| 71 | records retrieved to ensure that the plural data objects actually | ||
| 72 | consists of an array of L<AxKit::App::TABOO::Data::MediaType>s. But it | ||
| 73 | calls the internal C<_load()>-method to do the hard work (and that's | ||
| 74 | in the parent class). | ||
| 75 | |||
| 76 | If there is no data that corresponds to the given arguments, this | ||
| 77 | method will return C<undef>. | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | |||
| 82 | sub load { | ||
| 83 | my ($self, %args) = @_; | ||
| 84 | my $data = $self->_load(%args); # Does the hard work | ||
| 85 | return undef unless (@{$data}); | ||
| 86 | foreach my $entry (@{$data}) { | ||
| 87 | my $type = AxKit::App::TABOO::Data::MediaType->new($self->dbconnectargs()); | ||
| 88 | $type->populate($entry); | ||
| 89 | $type->onfile; | ||
| 90 | $self->Push($type); | ||
| 91 | } | ||
| 92 | return $self; | ||
| 93 | } | ||
| 94 | |||
| 95 | =back | ||
| 96 | |||
| 97 | =head1 BUGS/TODO | ||
| 98 | |||
| 99 | More accurate documentation. | ||
| 100 | |||
| 101 | |||
| 102 | =head1 FORMALITIES | ||
| 103 | |||
| 104 | See L<AxKit::App::TABOO>. | ||
| 105 | |||
| 106 | =cut | ||
| 107 | |||
| 108 | 1; | ||
| 109 | |||
| 110 |