Documentation.
[blog.pm-common-perl-mods.git] / Rose-DBx-Object-I18N / lib / Rose / DBx / Object / I18N / Manager.pm
blob7c3b49f6011fc66c22ce0d83857b3d8530933ea3
1 package Rose::DBx::Object::I18N::Manager;
3 use strict;
4 use warnings;
6 use base 'Rose::DB::Object::Manager';
8 use Rose::DBx::Object::I18N::Helpers ':all';
10 use Hash::Merge 'merge';
12 sub get_objects {
13 my $class = shift;
14 my %args = @_;
16 if ( my $language = (delete $args{ i18n } || $class->i18n_language()) ) {
17 my $rel_name = $class->object_class->meta->i18n_translation_rel_name();
19 my ( $rel ) = grep { $_->name => $rel_name }
20 $class->object_class->meta->relationships;
22 my ( $i18n_lang ) = grep { $_->type eq 'i18n_language' }
23 $rel->foreign_class->meta->columns;
24 my $i18n_lang_column = $i18n_lang->name;
26 my $new_args = merge {
27 query => [ "$rel_name.$i18n_lang_column" => $language ],
28 with_objects => [ $rel_name ]
30 \%args;
32 %args = %$new_args;
35 $class->SUPER::get_objects( %args );
38 =head1 COPYRIGHT & LICENSE
40 Copyright 2008 Viacheslav Tikhanovskii, all rights reserved.
42 This program is free software; you can redistribute it and/or modify it
43 under the same terms as Perl itself.
45 =cut