码迷,mamicode.com
首页 > 其他好文 > 详细

theme('item-list',array('items'=>array('aaa','bbb'))) 是如何运行的 ?

时间:2015-05-10 18:52:15      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

$items[‘items‘] = array(
    l(‘Configure‘, ‘admin/config‘),
    l(‘Structure‘, ‘admin/structure‘),
);
$theme =  theme(‘item_list‘, $items);

1,  判断是否所有的模块都加载了,

if (!module_load_all(NULL) && !defined(‘MAINTENANCE_MODE‘)) {
    throw new Exception(t(‘theme() may not be called until all modules are loaded.‘));
  }

2,  获得所有的ThemeRegistry信息, 这个信息就是所有模块定义的hook_theme的数组, 并合并了很多默认的信息, 比如process function, function, render array, variables,etc

 $hooks = theme_get_registry(FALSE);

3,  获得这次的ThemeHook所对应的ThemeRegistry信息

$info = $hooks[$hook];

4,  如果hook_theme定义了includes, 那就加载函数

if (!empty($info[‘includes‘])) {
    foreach ($info[‘includes‘] as $include_file) {
      include_once DRUPAL_ROOT . ‘/‘ . $include_file;
    }
  }

 5,  吧$variable和ThemeRegistry对应这次hook的variable合并

  if (!empty($info[‘variables‘])) {
    $variables += $info[‘variables‘];
  }

6, $info里面process preprocess function被调用

$processor_function($variables, $hook_clone);

7, 如果在process preprocess function里改变了$variable[‘theme_hook_suggestion‘]的话, 会重新加载$hook

 $info = $hooks[$suggestion];

8, $info里面的function会被调用来处理$variable

 $output = $info[‘function‘]($variables);

 

theme('item-list',array('items'=>array('aaa','bbb'))) 是如何运行的 ?

标签:

原文地址:http://www.cnblogs.com/qinqiu/p/4492565.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!