Additional DOM-like methods for AdjacencyList.
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / Manual / Component.pod
CommitLineData
3d18a9c1 1
2=head1 NAME
3
d444f9fa 4DBIx::Class::Manual::Component - Existing components and how to develop new ones.
3d18a9c1 5
6=head1 USING
7
8Components are loaded using the load_components() method within your
9DBIx::Class classes.
10
11 package My::Thing;
12 use base qw( DBIx::Class );
13 __PACKAGE__->load_components(qw( PK::Auto Core ));
14
15Generally you do not want to specify the full package name
16of a component, instead take off the DBIx::Class:: part of
17it and just include the rest. If you do want to load a
18component outside of the normal namespace you can do so
19by prepending the component name with a +.
20
21 __PACKAGE__->load_components(qw( +My::Component ));
22
23Once a component is loaded all of it's methods, or otherwise,
24that it provides will be available in your class.
25
26The order in which is you load the components may be
d444f9fa 27very important, depending on the component. The general
3d18a9c1 28rule of thumb is to first load extra components and then
29load core ones last. If you are not sure, then read the
30docs for the components you are using and see if they
31mention anything about the order in which you should load
32them.
33
d444f9fa 34=head1 EXISTING COMPONENTS
3d18a9c1 35
36=head2 Extra
37
d444f9fa 38These components provide extra functionality beyond
39basic functionality that you can't live without.
3d18a9c1 40
880a1a0c 41L<DBIx::Class::CDBICompat> - Class::DBI Compatibility layer.
3d18a9c1 42
3d18a9c1 43L<DBIx::Class::FormTools> - Build forms with multiple interconnected objects.
44
45L<DBIx::Class::HTMLWidget> - Like FromForm but with DBIx::Class and HTML::Widget.
46
d444f9fa 47L<DBIx::Class::PK::Auto> - Retrieve automatically created primary keys upon insert.
48
3d18a9c1 49L<DBIx::Class::QueriesTime> - Display the amount of time it takes to run queries.
50
51L<DBIx::Class::RandomStringColumns> - Declare virtual columns that return random strings.
52
53L<DBIx::Class::UTF8Columns> - Force UTF8 (Unicode) flag on columns.
54
55L<DBIx::Class::UUIDColumns> - Implicit UUID columns.
56
57L<DBIx::Class::WebForm> - CRUD methods.
58
59=head2 Experimental
60
61These components are under development, there interfaces may
62change, they may not work, etc. So, use them if you want, but
63be warned.
64
65L<DBIx::Class::Serialize> - Hooks for Storable freeze/thaw.
66
67L<DBIx::Class::Serialize::Storable> - Hooks for Storable freeze/thaw.
68
69L<DBIx::Class::Validation> - Validate all data before submitting to your database.
70
1e3ff014 71L<DBIx::Class::Positional> - Modify the position of objects in an ordered list.
72
73L<DBIx::Class::Tree::AdjacencyList> - Manage a tree of data using the common adjacency list model.
74
75L<DBIx::Class::Tree::NestedSet> - Manage a positional tree of data using the nested set model.
76
3d18a9c1 77=head2 Core
78
79These are the components that all, or nearly all, people will use
80without even knowing it. These components provide most of
81DBIx::Class' functionality.
82
d444f9fa 83L<DBIx::Class::AccessorGroup> - Lets you build groups of accessors.
84
3d18a9c1 85L<DBIx::Class::Core> - Loads various components that "most people" would want.
86
87L<DBIx::Class::DB> - Non-recommended classdata schema component.
88
89L<DBIx::Class::InflateColumn> - Automatically create objects from column data.
90
3d18a9c1 91L<DBIx::Class::PK> - This class contains methods for handling primary keys and methods depending on them.
92
d444f9fa 93L<DBIx::Class::Relationship> - Inter-table relationships.
3d18a9c1 94
95L<DBIx::Class::ResultSourceProxy::Table> - Provides a classdata table object and method proxies.
96
d444f9fa 97L<DBIx::Class::Row> - Basic row methods.
3d18a9c1 98
d444f9fa 99=head1 CREATEING COMPONENTS
3d18a9c1 100
101Making your own component is very easy.
102
103 package DBIx::Class::MyComp;
104 use base qw(DBIx::Class);
105 # Create methods, accessors, load other components, etc.
106 1;
107
108When a component is loaded it is included in the calling
d444f9fa 109class' inheritance chain using L<Class::C3>. As well as
3d18a9c1 110providing custom utility methods, a component may also
111override methods provided by other core components, like
112L<DBIx::Class::Row> and others. For example, you
113could override the insert and delete methods.
114
115 sub insert {
116 my $self = shift;
117 # Do stuff with $self, like set default values.
118 return $self->nest::method( @_ );
119 }
120
121 sub delete {
122 my $self = shift;
123 # Do stuff with $self.
124 return $self->nest::method( @_ );
125 }
126
127Now, the order that a component is loaded is very important. Components
128that are loaded first are the first ones in the inheritance stack. So, if
129you override insert() but the DBIx::Class::Row component is loaded first
130then your insert() will never be called, since the DBIx::Class::Row insert()
131will be called first. If you are unsure as to why a given method is not
132being called try printing out the Class::C3 inheritance stack.
133
134 print join ', ' => Class::C3::calculateMRO('YourClass::Name');
135
880a1a0c 136Check out the L<Class::C3> docs for more information about inheritance.
3d18a9c1 137
138=head1 SEE ALSO
139
140L<DBIx::Class::Manual::Cookbook>
141
142L<DBIx::Class::Manual::FAQ>
143
144=head1 AUTHOR
145
146Aran Clary Deltac <bluefeet@cpan.org>
147