| 1 | 2 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | |||
| 3 | package Interchange6::Schema; | ||
| 4 | |||
| 5 | =encoding utf8 | ||
| 6 | |||
| 7 | =head1 NAME | ||
| 8 | |||
| 9 | Interchange6::Schema - Database Schema for Interchange 6 | ||
| 10 | |||
| 11 | =head1 VERSION | ||
| 12 | |||
| 13 | 0.130 | ||
| 14 | |||
| 15 | =cut | ||
| 16 | |||
| 17 | 2 | our $VERSION = '0.130'; | |
| 18 | |||
| 19 | =head1 MANUAL | ||
| 20 | |||
| 21 | Please see the L<Interchange6 Schema Manual|Interchange6::Schema::Manual> | ||
| 22 | for an overview of available documentation. | ||
| 23 | |||
| 24 | =head1 DESCRIPTION | ||
| 25 | |||
| 26 | Database schema classes for Interchange6 Open Source eCommerce software. | ||
| 27 | |||
| 28 | The minimum Perl version for Interchange6::Schema is 5.8. | ||
| 29 | |||
| 30 | =head1 BASE CLASS | ||
| 31 | |||
| 32 | L<DBIx::Class::Schema::Config> | ||
| 33 | |||
| 34 | If you inherit from L<Interchange6::Schema> then in order to make use of | ||
| 35 | L<DBIx::Class::Schema::Config> in your own schema you must load it as a | ||
| 36 | component. | ||
| 37 | |||
| 38 | =head1 COMPONENTS | ||
| 39 | |||
| 40 | Components used: | ||
| 41 | |||
| 42 | =over | ||
| 43 | |||
| 44 | =item * L<DBIx::Class::Helper::Schema::DateTime> | ||
| 45 | |||
| 46 | =item * L<DBIx::Class::Helper::Schema::QuoteNames> | ||
| 47 | |||
| 48 | =back | ||
| 49 | |||
| 50 | =cut | ||
| 51 | |||
| 52 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 53 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 54 | |||
| 55 | 2 | ▶ | use base 'DBIx::Class::Schema::Config'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 56 | |||
| 57 | 2 | __PACKAGE__->load_components( 'Helper::Schema::DateTime', | |
| 58 | 'Helper::Schema::QuoteNames' ); | ||
| 59 | |||
| 60 | 2 | __PACKAGE__->load_namespaces( | |
| 61 | default_resultset_class => 'ResultSet', | ||
| 62 | ); | ||
| 63 | |||
| 64 | =head1 ATTRIBUTES | ||
| 65 | |||
| 66 | =head2 current_user | ||
| 67 | |||
| 68 | This attribute can be used to stash the L<Interchange6::Schema::Result::User> | ||
| 69 | object of the currently logged in user. If set then any result class and | ||
| 70 | resultset methods which take C<users_id> as an argument will make use of | ||
| 71 | the value of this attribute to set C<users_id>. | ||
| 72 | |||
| 73 | =over | ||
| 74 | |||
| 75 | =item writer: set_current_user | ||
| 76 | |||
| 77 | =back | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | =head2 user_locale | ||
| 82 | |||
| 83 | This attribute can be used to store the locale of the current user. | ||
| 84 | |||
| 85 | =over | ||
| 86 | |||
| 87 | =item writer: set_user_locale | ||
| 88 | |||
| 89 | =back | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | 2 | __PACKAGE__->mk_group_ro_accessors( | |
| 94 | inherited => ( | ||
| 95 | [ 'current_user' => '_ic6_current_user' ], | ||
| 96 | [ 'user_locale' => '_ic6_user_locale' ], | ||
| 97 | ) | ||
| 98 | ); | ||
| 99 | |||
| 100 | 2 | __PACKAGE__->mk_group_wo_accessors( | |
| 101 | inherited => ( | ||
| 102 | [ 'set_current_user' => '_ic6_current_user' ], | ||
| 103 | [ 'set_user_locale' => '_ic6_user_locale' ], | ||
| 104 | ) | ||
| 105 | ); | ||
| 106 | |||
| 107 | =head1 METHODS | ||
| 108 | |||
| 109 | =head2 deploy | ||
| 110 | |||
| 111 | Overload L<DBIx::Class::Schema/deploy> in order to add some core fixtures | ||
| 112 | via L<Interchange6::Schema::Populate>. | ||
| 113 | |||
| 114 | =cut | ||
| 115 | |||
| 116 | { | ||
| 117 | 2 | ▶ | use Interchange6::Schema::Populate; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 118 | |||
| 119 | sub deploy { | ||
| 120 | 1 | ▶ | my $self = shift; |
|
Subroutine
deploy: called CC=1 SCAR=0.0
Pod
documented
| |||
| 121 | 1 | my $new = $self->next::method(@_); | |
| 122 | |||
| 123 | 1 | Interchange6::Schema::Populate->new( schema => $self )->populate; | |
| 124 | |||
| 125 | # $self->resultset('Website')->create( | ||
| 126 | # { | ||
| 127 | # fqdn => "*", | ||
| 128 | # name => "Default", | ||
| 129 | # description => "Default Website" | ||
| 130 | # } | ||
| 131 | # ); | ||
| 132 | } | ||
| 133 | } | ||
| 134 | |||
| 135 | 2 | 1; | |
| 136 | |||
| 137 | __END__ | ||
| 138 | |||
| 139 | =head1 CREATE SQL FILES FOR DATABASE SCHEMA | ||
| 140 | |||
| 141 | This command creates SQL files for our database schema | ||
| 142 | in the F<sql/> directory: | ||
| 143 | |||
| 144 | interchange6-create-database | ||
| 145 | |||
| 146 | =head1 POLICY FOR RELATIONSHIP ACCESSORS | ||
| 147 | |||
| 148 | =over 4 | ||
| 149 | |||
| 150 | =item All lower case | ||
| 151 | |||
| 152 | =item Singular names for belongs_to and has_one relationships | ||
| 153 | |||
| 154 | =item Pluralised names for many_to_many and has_many relationships | ||
| 155 | |||
| 156 | =item Use underscores for things like C<shipment_destinations>. | ||
| 157 | |||
| 158 | =back | ||
| 159 | |||
| 160 | =head1 AUTHORS | ||
| 161 | |||
| 162 | Stefan Hornburg (Racke), C<racke@linuxia.de> | ||
| 163 | |||
| 164 | Peter Mottram, C<peter@sysnix.com> | ||
| 165 | |||
| 166 | Jeff Boes, C<jeff@endpoint.com> | ||
| 167 | |||
| 168 | Sam Batschelet C<sbatschelet@mac.com> | ||
| 169 | |||
| 170 | =head1 CONTRIBUTORS | ||
| 171 | |||
| 172 | Kaare Rasmussen | ||
| 173 | Šimun Kodžoman | ||
| 174 | Grega Pompe | ||
| 175 | |||
| 176 | =head1 LICENSE AND COPYRIGHT | ||
| 177 | |||
| 178 | Copyright 2013-2014 Stefan Hornburg (Racke), Jeff Boes. | ||
| 179 | |||
| 180 | This program is free software; you can redistribute it and/or modify it | ||
| 181 | under the terms of either: the GNU General Public License as published | ||
| 182 | by the Free Software Foundation; or the Artistic License. | ||
| 183 | |||
| 184 | See http://dev.perl.org/licenses/ for more information. | ||