Filename | /var/www/foswikidev/core/lib/Foswiki/Configure/Wizard.pm |
Statements | Executed 7 statements in 236µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 14µs | 28µs | BEGIN@35 | Foswiki::Configure::Wizard::
1 | 1 | 1 | 11µs | 37µs | BEGIN@38 | Foswiki::Configure::Wizard::
1 | 1 | 1 | 9µs | 13µs | BEGIN@36 | Foswiki::Configure::Wizard::
0 | 0 | 0 | 0s | 0s | loadWizard | Foswiki::Configure::Wizard::
0 | 0 | 0 | 0s | 0s | new | Foswiki::Configure::Wizard::
0 | 0 | 0 | 0s | 0s | param | Foswiki::Configure::Wizard::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # See bottom of file for license and copyright information | ||||
2 | package Foswiki::Configure::Wizard; | ||||
3 | |||||
4 | =begin TML | ||||
5 | |||||
6 | ---++ package Foswiki::Configure::Wizard | ||||
7 | |||||
8 | A Wizard is module that performs one or more configuration functions. | ||||
9 | For example, you might have a wizard that helps set up email; | ||||
10 | when you have all the email settings done, you invoke the wizard | ||||
11 | to attempt to complete the configuration. | ||||
12 | |||||
13 | Any number of callable functions may be defined in a wizard. | ||||
14 | Each function _fn_ has the signature: | ||||
15 | |||||
16 | =ObjectMethod _fn_ ($reporter, $spec) -> $boolean= | ||||
17 | |||||
18 | Wizards can accept | ||||
19 | values from callers using the =$this->param()= method. Error messages | ||||
20 | etc are reported via the =Foswiki::Configure::Reporter $reporter=. | ||||
21 | |||||
22 | $spec is the root of the type specification tree for configuration entries. | ||||
23 | This is provided primarily for wizards that need to modify it e.g. | ||||
24 | installers. | ||||
25 | |||||
26 | Wizard functions may modify =$Foswiki::cfg=, but must report | ||||
27 | any such changes that have to persist using the | ||||
28 | =$reporter->CHANGED= method. | ||||
29 | |||||
30 | It's up to the UI how wizards are called, and their results returned. | ||||
31 | See the documentation for the UI for more information. | ||||
32 | |||||
33 | =cut | ||||
34 | |||||
35 | 2 | 27µs | 2 | 41µs | # spent 28µs (14+13) within Foswiki::Configure::Wizard::BEGIN@35 which was called:
# once (14µs+13µs) by Foswiki::Plugins::ConfigurePlugin::BEGIN@43 at line 35 # spent 28µs making 1 call to Foswiki::Configure::Wizard::BEGIN@35
# spent 13µs making 1 call to strict::import |
36 | 2 | 30µs | 2 | 17µs | # spent 13µs (9+4) within Foswiki::Configure::Wizard::BEGIN@36 which was called:
# once (9µs+4µs) by Foswiki::Plugins::ConfigurePlugin::BEGIN@43 at line 36 # spent 13µs making 1 call to Foswiki::Configure::Wizard::BEGIN@36
# spent 4µs making 1 call to warnings::import |
37 | |||||
38 | 2 | 177µs | 2 | 63µs | # spent 37µs (11+26) within Foswiki::Configure::Wizard::BEGIN@38 which was called:
# once (11µs+26µs) by Foswiki::Plugins::ConfigurePlugin::BEGIN@43 at line 38 # spent 37µs making 1 call to Foswiki::Configure::Wizard::BEGIN@38
# spent 26µs making 1 call to Exporter::import |
39 | |||||
40 | =begin TML | ||||
41 | |||||
42 | ---++ StaticMethod loadWizard($name, $param_source) -> $wizard | ||||
43 | |||||
44 | Loads the Foswiki::Configure::Wizards subclass identified | ||||
45 | by $name. =$param_source= is a reference to an object that | ||||
46 | supports the =param()= method for getting parameter values. | ||||
47 | |||||
48 | =cut | ||||
49 | |||||
50 | sub loadWizard { | ||||
51 | my ( $name, $param_source ) = @_; | ||||
52 | |||||
53 | ASSERT( $name =~ m/^[A-Za-z][A-Za-z0-9]+$/ ) if DEBUG; | ||||
54 | |||||
55 | my $class = 'Foswiki::Configure::Wizards::' . $name; | ||||
56 | |||||
57 | eval("require $class"); | ||||
58 | die "Failed to load wizard $class: $@" if $@; | ||||
59 | |||||
60 | return $class->new($param_source); | ||||
61 | } | ||||
62 | |||||
63 | sub new { | ||||
64 | my ( $class, $ps ) = @_; | ||||
65 | return bless( { param_source => $ps }, $class ); | ||||
66 | } | ||||
67 | |||||
68 | =begin TML | ||||
69 | |||||
70 | ---++ ObjectMethod param($name) -> $value | ||||
71 | |||||
72 | Returns the value of a parameter that was given when the wizard was invoked. | ||||
73 | |||||
74 | =cut | ||||
75 | |||||
76 | sub param { | ||||
77 | my ( $this, $param ) = @_; | ||||
78 | return $this->{param_source}->{$param}; | ||||
79 | } | ||||
80 | |||||
81 | 1 | 2µs | 1; |