我的hook_schema有一些辅助功能:
function _bbcmap_schema_asr_field($description) {
return array(
'type' => 'int',
'unsigned' => TRUE,
'size' => 'small', // Up to ~66k with MySQL (equivalent up to ~660.00 adjusted)
'not null' => FALSE,
'description' => t($description),
);
}
然后,我可以像这样使用它:
/**
* Implements hook_schema().
*/
function bbcmap_schema() {
$schema['la_data'] = array(
'fields' => array(
...
'mort_asr_male' => _bbcmap_schema_asr_field('The age standardised mortality amongst men (fixed point with scale factor 1/100)'),
'mort_asr_female' => _bbcmap_schema_asr_field('The age standardised mortality amongst women (fixed point with scale factor 1/100)'),
'incid_asr_male' => _bbcmap_schema_asr_field('The age standardised incidence amongst men (fixed point with scale factor 1/100)'),
'incid_asr_female' => _bbcmap_schema_asr_field('The age standardised incidence amongst women (fixed point with scale factor 1/100)'),
...
),
);
}
我知道准则是不传递变量,t()
但是这与菜单系统t()
(默认情况下)传递回调标题的方式非常相似。关于这种风格的好坏有何评论?