本文整理汇总了PHP中TimberHelper::start_timer方法的典型用法代码示例。如果您正苦于以下问题:PHP TimberHelper::start_timer方法的具体用法?PHP TimberHelper::start_timer怎么用?PHP TimberHelper::start_timer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimberHelper
的用法示例。
在下文中一共展示了TimberHelper::start_timer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTimers
function testTimers()
{
$start = TimberHelper::start_timer();
sleep(1);
$end = TimberHelper::stop_timer($start);
$this->assertContains(' seconds.', $end);
$time = str_replace(' seconds.', '', $end);
$this->assertGreaterThan(1, $time);
}
示例2: TimberPost
<?php
/**
* The main template file.
*/
// set up page data
$template = false;
$start = TimberHelper::start_timer();
$data = Timber::get_context();
$data['latest_news'] = get_fg_latest_posts();
if (is_singular()) {
$data['post'] = new TimberPost();
} else {
$data['posts'] = Timber::get_posts();
}
$data['config'] = $get_config();
$data['menu'] = new TimberMenu('main-menu');
if (is_single()) {
$template = 'single';
$data['slideshow'] = $get_slideshow();
} elseif (is_page()) {
$matches = null;
$template = 'page';
// for custom templates
$returnValue = preg_match('/.*\\/(.*?)\\./', get_page_template(), $matches);
if ($returnValue) {
$template = 'page-' . $matches[1];
}
$data['slideshow'] = $get_slideshow();
} elseif (is_home()) {
$template = 'index';
示例3: handle_post_results
public static function handle_post_results($results, $PostClass = 'TimberPost')
{
$start = TimberHelper::start_timer();
$posts = array();
foreach ($results as $rid) {
$PostClassUse = $PostClass;
if (is_array($PostClass)) {
$post_type = get_post_type($rid);
$PostClassUse = 'TimberPost';
if (isset($PostClass[$post_type])) {
$PostClassUse = $PostClass[$post_type];
} else {
if (is_array($PostClass)) {
TimberHelper::error_log($post_type . ' of ' . $rid . ' not found in ' . print_r($PostClass, true));
} else {
TimberHelper::error_log($post_type . ' not found in ' . $PostClass);
}
}
}
$post = new $PostClassUse($rid);
if (isset($post->ID)) {
$posts[] = $post;
}
}
return $posts;
}