Revision 1918cfae
Von Kivitendo Admin vor fast 8 Jahren hinzugefügt
SL/DB/Helper/Presenter.pm | ||
---|---|---|
32 | 32 |
|
33 | 33 |
=head1 SYNOPSIS |
34 | 34 |
|
35 |
# assuming SL::Presemter::Part exists
|
|
35 |
# assuming SL::Presenter::Part exists
|
|
36 | 36 |
# and contains a sub link_to($class, $object) {} |
37 | 37 |
SL::DB::Part->new(%args)->presenter->link_to |
38 | 38 |
|
39 | 39 |
=head1 DESCRIPTION |
40 | 40 |
|
41 |
When coding controller one often encounters objects that are not crucial to the
|
|
42 |
current task, but must be presented in some form to the user. Instead of |
|
41 |
When coding controllers one often encounters objects that are not crucial to
|
|
42 |
the current task, but must be presented in some form to the user. Instead of
|
|
43 | 43 |
recreating that all the time the C<SL::Presenter> namepace was introduced to |
44 | 44 |
hold such code. |
45 | 45 |
|
46 | 46 |
Unfortunately the Presenter code is designed to be stateless and thus acts _on_ |
47 | 47 |
objects, but can't be instanced or wrapped. The early band-aid to that was to |
48 | 48 |
export all sub-presenter calls into the main presenter namespace. Fixing it |
49 |
would have meant to access presenter functions like this:
|
|
49 |
would have meant accessing presenter functions like this:
|
|
50 | 50 |
|
51 | 51 |
SL::Presenter::Object->method($object, %additional_args) |
52 | 52 |
|
53 |
which is extremely inconvenient.
|
|
53 |
which is extremely inconvenient. |
|
54 | 54 |
|
55 | 55 |
This glue code allows C<SL::DB::Object> instances to access routines in their |
56 | 56 |
presenter without additional boilerplate. C<SL::DB::Object> contains a |
... | ... | |
59 | 59 |
|
60 | 60 |
=head1 INTERNAL STRUCTURE |
61 | 61 |
|
62 |
The proxy objects created are lightweight blessed arrayrefs instead of the usual blessed
|
|
63 |
hashrefs. They only store two elements: |
|
62 |
The created proxy objects are lightweight blessed arrayrefs instead of the
|
|
63 |
usual blessed hashrefs. They only store two elements:
|
|
64 | 64 |
|
65 | 65 |
=over 4 |
66 | 66 |
|
Auch abrufbar als: Unified diff
Typos in Doku