Hook
Overview
Hooks are required to resolve complicated problems or for compilcated
customization. But there are several problems in implemantation.
One problem is naming convension.
$START_HOOK of &fml4; is ambiguous.
It means the location in process but not clarify where in which process.
So, &fml8; hook naming convension has role and function in it.
$ROLE_FUNCTION_start_hook
$ROLE_FUNCTION_end_hook
There is no common hook among processes. Each process has each hook.
In other words, there is no common hook. You need to define plural
hooks for different processes even if the hook is same content.
$distribute_XXX_start_hook = q{ ... };
$YYY_XXX_start_hook = $distribute_XXX_start_hook;
Coding style of hooks are expected not too restrictive
since perl beginners may code it.
&fml8; modules have
use strict;
definition but not effective in evalauating hooks.
In evaluating a hook, &fml8; evaluate it as
no strict;
HOOK CONTENT
to disable the strict check.
Function scope differs among &fml4; and &fml8;.
In &fml4; all functions are global.
Instead in &fml8; functions are methods, which is not called anytime anywhere.
We should provide hooks when we can see $curproc.
Hook Naming Convension
Hook standard form is
ROLE_METHOD_start_hook
ROLE_METHOD_end_hook
The role is "ROLE" part of $use_ROLE_function
(e.g. $use_article_post_function) in configuration variables.
This hook directory corresponds to some variables in configuration.
More granular hooks do not match this rule.
For example, the main part of fmlconf command, run() method, provide
the following hooks:
fmlconf_run_start_hook
fmlconf_run_end_hook
The actual code calling hooks as follows:
sub run
{
my ($curproc, $args) = @_;
my $config = $curproc->{ config };
my $eval = $config->get_hook( 'fmlconf_run_start_hook' );
if ($eval) {
eval qq{ $eval; };
print STDERR $@ if $@;
}
$curproc->_fmlconf($args);
$eval = $config->get_hook( 'fmlconf_run_end_hook' );
if ($eval) {
eval qq{ $eval; };
print STDERR $@ if $@;
}
}
This case is fundamental. More granular hooks must be needed.
The naming convension may differ from this convension.
Recipes
§.hook.recipes;