本文整理汇总了PHP中Debug::markMilestone方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::markMilestone方法的具体用法?PHP Debug::markMilestone怎么用?PHP Debug::markMilestone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debug
的用法示例。
在下文中一共展示了Debug::markMilestone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the instance of a given hook
*
* @param string $namespace The namespace (addon/aspect) calling the hook
* @param string $hook Name of hook
* @param string $type Cumulative/replace/call
* @param mixed $return Pass-through values
* @param mixed $data Data to pass to hooked method
* @return mixed
*/
public static function run($namespace, $hook, $type = NULL, $return = NULL, $data = NULL)
{
$mark_as_init = !self::$hooks_found;
if (!self::$hooks_found) {
$hash = Debug::markStart('hooks', 'finding');
// we went finding
self::$hooks_found = true;
// set paths
$addons_path = BASE_PATH . Config::getAddOnsPath();
$bundles_path = APP_PATH . '/core/bundles';
$pattern = '/*/hooks.*.php';
// globbing with a brace doesn't seem to work on some system,
// it's not just Windows-based servers, seems to affect some
// linux-based ones too
$bundles = glob($bundles_path . $pattern);
$addons = glob($addons_path . $pattern);
$bundles = empty($bundles) ? array() : $bundles;
$addons = empty($addons) ? array() : $addons;
self::$hook_files = array_merge($bundles, $addons);
Debug::markEnd($hash);
}
$hash = Debug::markStart('hooks', 'running');
if (self::$hook_files) {
foreach (self::$hook_files as $file) {
$name = substr($file, strrpos($file, '/') + 7);
$name = substr($name, 0, strlen($name) - 4);
$class_name = 'Hooks_' . $name;
if (!is_callable(array($class_name, $namespace . '__' . $hook), false)) {
continue;
}
try {
$hook_class = Resource::loadHooks($name);
$method = $namespace . '__' . $hook;
if ($type == 'cumulative') {
$response = $hook_class->{$method}($data);
if (is_array($response)) {
$return = is_array($return) ? $return + $response : $response;
} else {
$return .= $response;
}
} elseif ($type == 'replace') {
$return = $hook_class->{$method}($data);
} else {
$hook_class->{$method}($data);
}
} catch (Exception $e) {
continue;
}
}
}
if ($mark_as_init) {
Debug::markMilestone('hooks initialized');
}
Debug::markEnd($hash);
return $return;
}
示例2: run
/**
* Run the instance of a given hook
*
* @param string $namespace The namespace (addon/aspect) calling the hook
* @param string $hook Name of hook
* @param string $type Cumulative/replace/call
* @param mixed $return Pass-through values
* @param mixed $data Data to pass to hooked method
* @return mixed
*/
public static function run($namespace, $hook, $type = NULL, $return = NULL, $data = NULL)
{
$mark_as_init = !self::$hooks_found;
if (!self::$hooks_found) {
$hash = Debug::markStart('hooks', 'finding');
// we went finding
self::$hooks_found = true;
// set paths
$addons_path = BASE_PATH . Config::getAddOnsPath();
$bundles_path = APP_PATH . '/core/bundles';
$pattern = '/*/hooks.*.php';
// muuulllllti-gloooobbb
self::$hook_files = glob('{' . $bundles_path . $pattern . ',' . $addons_path . $pattern . '}', GLOB_BRACE);
Debug::markEnd($hash);
}
$hash = Debug::markStart('hooks', 'running');
if (self::$hook_files) {
foreach (self::$hook_files as $file) {
$name = substr($file, strrpos($file, '/') + 7);
$name = substr($name, 0, strlen($name) - 4);
$class_name = 'Hooks_' . $name;
if (!is_callable(array($class_name, $namespace . '__' . $hook), false)) {
continue;
}
try {
$hook_class = Resource::loadHooks($name);
$method = $namespace . '__' . $hook;
if ($type == 'cumulative') {
$response = $hook_class->{$method}($data);
if (is_array($response)) {
$return = is_array($return) ? $return + $response : $response;
} else {
$return .= $response;
}
} elseif ($type == 'replace') {
$return = $hook_class->{$method}($data);
} else {
$hook_class->{$method}($data);
}
} catch (Exception $e) {
continue;
}
}
}
if ($mark_as_init) {
Debug::markMilestone('hooks initialized');
}
Debug::markEnd($hash);
return $return;
}
示例3: spl_autoload_register
|--------------------------------------------------------------------------
| The Template Parser
|--------------------------------------------------------------------------
|
| Statamic uses a *highly* modified fork of the Lex parser, created by
| Dan Horrigan. Kudos Dan!
|
*/
require_once __DIR__ . '/vendor/Lex/Parser.php';
/*
|--------------------------------------------------------------------------
| Internal API & Class Autoloader
|--------------------------------------------------------------------------
|
| An autoloader for our internal API and other core classes
|
*/
// helper functions
require_once __DIR__ . '/core/exceptions.php';
require_once __DIR__ . '/core/functions.php';
// register the Statamic autoloader
spl_autoload_register("autoload_statamic");
// attempt HTML caching
// although this doesn't really have anything to do with autoloading, putting this
// here allows us to not force people to update their index.php files
if (Addon::getAPI('html_caching')->isEnabled() && Addon::getAPI('html_caching')->isPageCached()) {
die(Addon::getAPI('html_caching')->getCachedPage());
}
// mark milestone for debug panel
Debug::markMilestone('autoloaders ready');
示例4:
|--------------------------------------------------------------------------
|
| Numerous tag variables, helpers, and other config-dependent options
| need to be loaded *before* the page is parsed.
|
*/
Statamic::setDefaultTags();
// mark milestone for debug panel
Debug::markMilestone('app defaults set');
/*
|--------------------------------------------------------------------------
| Caching
|--------------------------------------------------------------------------
|gt
| Look for updated content to cache
|
*/
_Cache::update();
//_Cache::dump();
// mark milestone for debug panel
Debug::markMilestone('caches updated');
/*
|--------------------------------------------------------------------------
| The Routes
|--------------------------------------------------------------------------
|
| Route it up fellas!
|
*/
require_once __DIR__ . '/routes.php';
return $app;
示例5:
Statamic_View::set_templates(array_reverse($template_list));
/*
|--------------------------------------------------------------------------
| HTTP Caching
|--------------------------------------------------------------------------
|
| We'll always set the last modified header, but leave the
| cache_expires option to people's discretion and configuration.
|
*/
if (array_get($data, '_http_cache_expires', Config::get('http_cache_expires', false))) {
$app->lastModified(Cache::getLastCacheUpdate());
$app->expires('+'.Config::get('http_cache_expires', '30 minutes'));
}
// append the response code
$data['_http_status'] = $response_code;
$data['_response'] = $response_code;
// and go!
$app->render(null, $data, $response_code);
// mark milestone for debug panel
Debug::markMilestone('render end');
$app->halt($response_code, ob_get_clean());
})->via('GET', 'POST', 'HEAD');
示例6: render
/**
* render
* Finds and chooses the correct template, then renders the page
*
* @param string $template Template (or array of templates, in order of preference) to render the page with
* @return string
*/
public function render($template)
{
$html = '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">No template found.</p>';
$list = $template ? $list = array($template) : self::$_templates;
$template_type = 'html';
// Allow setting where to get the template from
if (!self::$_template_location) {
self::$_template_location = Path::assemble(BASE_PATH, Config::getTemplatesPath(), 'templates');
}
foreach ($list as $template) {
$template_path = Path::assemble(self::$_template_location, $template);
$override_path = Path::assemble(BASE_PATH, Config::getThemesPath(), Config::getTheme(), 'admin', $template);
if (File::exists($template_path . '.html') || file_exists($template_path . '.php')) {
// set debug information
Debug::setValue('template', $template);
Debug::setvalue('layout', str_replace('layouts/', '', self::$_layout));
Debug::setValue('statamic_version', STATAMIC_VERSION);
Debug::setValue('php_version', phpversion());
Debug::setValue('theme', array_get($this->data, '_theme', null));
Debug::setValue('environment', array_get($this->data, 'environment', '(none)'));
$this->data['_debug'] = array('template' => Debug::getValue('template'), 'layout' => Debug::getValue('layout'), 'version' => Debug::getValue('statamic_version'), 'statamic_version' => Debug::getValue('statamic_version'), 'php_version' => Debug::getValue('php_version'), 'theme' => Debug::getValue('theme'), 'environment' => Debug::getValue('environment'));
# standard lex-parsed template
if (File::exists($template_path . '.html')) {
$template_type = 'html';
$this->appendNewData($this->data);
// Fetch template and parse any front matter
$template = Parse::frontMatter(File::get($template_path . '.html'));
self::$_extra_data = $template['data'] + self::$_extra_data;
$this->prependNewData(self::$_extra_data);
$html = Parse::template($template['content'], Statamic_View::$_dataStore, array($this, 'callback'));
break;
# lets forge into raw data
} elseif (File::exists($override_path . '.php') || File::exists($template_path . '.php')) {
$template_type = 'php';
extract($this->data);
ob_start();
if (File::exists($override_path . '.php')) {
$template_path = $override_path;
}
require $template_path . ".php";
$html = ob_get_clean();
break;
} else {
Log::error("Template does not exist: '{$template_path}'", 'core');
}
}
}
// mark milestone for debug panel
Debug::markMilestone('template rendered');
// get rendered HTML
$rendered = $this->_render_layout($html, $template_type);
// mark milestone for debug panel
Debug::markMilestone('layout rendered');
// store it into the HTML cache if needed
if (Addon::getAPI('html_caching')->isEnabled()) {
Addon::getAPI('html_caching')->putCachedPage($rendered);
}
// return rendered HTML
return $rendered;
}