本文整理汇总了PHP中Debug::saveTimer方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::saveTimer方法的具体用法?PHP Debug::saveTimer怎么用?PHP Debug::saveTimer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Debug
的用法示例。
在下文中一共展示了Debug::saveTimer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preload
/**
* Convert all ModulePlaceholders to Fieldtype modules
*
*/
protected function preload()
{
if ($this->preloaded) {
return;
}
$debug = $this->wire('config')->debug;
if ($debug) {
Debug::timer('Fieldtypes.preload');
}
foreach ($this->data as $key => $module) {
if ($module instanceof ModulePlaceholder) {
$fieldtype = $this->wire('modules')->get($module->className());
$this->data[$key] = $fieldtype;
}
}
if ($debug) {
Debug::saveTimer('Fieldtypes.preload');
}
$this->preloaded = true;
}
示例2: ___execute
/**
* Execute the process and return the resulting content generated by the process
*
* @return string
* @throws ProcessController404Exception
*
*/
public function ___execute()
{
$content = '';
$debug = $this->wire('config')->debug;
$breadcrumbs = $this->wire('breadcrumbs');
$headline = $this->wire('processHeadline');
$numBreadcrumbs = $breadcrumbs ? count($breadcrumbs) : null;
if ($process = $this->getProcess()) {
if ($method = $this->getProcessMethodName($this->process)) {
$className = $this->process->className();
if ($debug) {
Debug::timer("{$className}.{$method}()");
}
$content = $this->process->{$method}();
if ($debug) {
Debug::saveTimer("{$className}.{$method}()");
}
if ($method != 'execute') {
// some method other than the main one
if (!is_null($numBreadcrumbs) && $numBreadcrumbs === count($breadcrumbs)) {
// process added no breadcrumbs, but there should be more
if ($headline === $this->wire('processHeadline')) {
$process->headline(str_replace('execute', '', $method));
}
$moduleInfo = $this->wire('modules')->getModuleInfo($process);
$href = substr($this->wire('input')->url(), -1) == '/' ? '../' : './';
$process->breadcrumb($href, $moduleInfo['title']);
}
}
} else {
throw new ProcessController404Exception("Unrecognized path");
}
} else {
throw new ProcessController404Exception("The requested process does not exist");
}
return $content;
}
示例3: __call
/**
* Provides the gateway for calling hooks in ProcessWire
*
* When a non-existant method is called, this checks to see if any hooks have been defined and sends the call to them.
*
* Hooks are defined by preceding the "hookable" method in a descending class with 3 underscores, like __myMethod().
* When the API calls $myObject->myMethod(), it gets sent to $myObject->___myMethod() after any 'before' hooks have been called.
* Then after the ___myMethod() call, any "after" hooks are then called. "after" hooks have the opportunity to change the return value.
*
* Hooks can also be added for methods that don't actually exist in the class, allowing another class to add methods to this class.
*
* See the Wire::runHooks() method for the full implementation of hook calls.
*
* @param string $method
* @param array $arguments
* @return mixed
* @throws WireException
*
*/
public function __call($method, $arguments)
{
if (self::___debug) {
static $timers = array();
$timerName = get_class($this) . "::{$method}";
$notes = array();
foreach ($arguments as $argument) {
if (is_object($argument)) {
$notes[] = get_class($argument);
} else {
if (is_array($argument)) {
$notes[] = "array(" . count($argument) . ")";
} else {
if (strlen($argument) > 20) {
$notes[] = substr($argument, 0, 20) . '...';
}
}
}
}
$timerName .= "(" . implode(', ', $notes) . ")";
if (isset($timers[$timerName])) {
$timers[$timerName]++;
$timerName .= " #" . $timers[$timerName];
} else {
$timers[$timerName] = 1;
}
Debug::timer($timerName);
$result = $this->runHooks($method, $arguments);
Debug::saveTimer($timerName);
} else {
$result = $this->runHooks($method, $arguments);
}
if (!$result['methodExists'] && !$result['numHooksRun']) {
if ($this->wire('config')->disableUnknownMethodException) {
return null;
}
throw new WireException("Method " . $this->className() . "::{$method} does not exist or is not callable in this context");
}
return $result['return'];
}
示例4: __call
/**
* Provides the gateway for calling hooks in ProcessWire
*
* When a non-existant method is called, this checks to see if any hooks have been defined and sends the call to them.
*
* Hooks are defined by preceding the "hookable" method in a descending class with 3 underscores, like __myMethod().
* When the API calls $myObject->myMethod(), it gets sent to $myObject->___myMethod() after any 'before' hooks have been called.
* Then after the ___myMethod() call, any "after" hooks are then called. "after" hooks have the opportunity to change the return value.
*
* Hooks can also be added for methods that don't actually exist in the class, allowing another class to add methods to this class.
*
* See the Wire::runHooks() method for the full implementation of hook calls.
*
* @param string $method
* @param array $arguments
* @return mixed
* @throws WireException
*
*/
public function __call($method, $arguments)
{
if (self::___debug) {
static $timers = array();
$timerName = get_class($this) . "::{$method}";
$notes = array();
foreach ($arguments as $argument) {
if (is_object($argument)) {
$notes[] = get_class($argument);
} else {
if (is_array($argument)) {
$notes[] = "array(" . count($argument) . ")";
} else {
if (strlen($argument) > 20) {
$notes[] = substr($argument, 0, 20) . '...';
}
}
}
}
$timerName .= "(" . implode(', ', $notes) . ")";
if (isset($timers[$timerName])) {
$timers[$timerName]++;
$timerName .= " #" . $timers[$timerName];
} else {
$timers[$timerName] = 1;
}
Debug::timer($timerName);
$result = $this->runHooks($method, $arguments);
Debug::saveTimer($timerName);
} else {
$result = $this->runHooks($method, $arguments);
}
if (!$result['methodExists'] && !$result['numHooksRun']) {
return $this->callUnknown($method, $arguments);
}
return $result['return'];
}
示例5: ___ready
/**
* Hookable ready for anyone that wants to hook immediately before any autoload modules ready or after all modules ready
*
*/
protected function ___ready()
{
if ($this->debug) {
Debug::timer('boot.modules.autoload.ready');
}
$this->wire('modules')->triggerReady();
if ($this->debug) {
Debug::saveTimer('boot.modules.autoload.ready');
}
}
示例6: ___find
//.........这里部分代码省略.........
}
if (isset($options['include']) && in_array($options['include'], array('hidden', 'unpublished', 'all'))) {
$selectorString .= ", include={$options['include']}";
}
// see if this has been cached and return it if so
$pages = $this->getSelectorCache($selectorString, $options);
if (!is_null($pages)) {
if ($debug) {
$this->debugLog('find', $selectorString, $pages . ' [from-cache]');
}
return $pages;
}
// check if this find has already been executed, and return the cached results if so
// if(null !== ($pages = $this->getSelectorCache($selectorString, $options))) return clone $pages;
// if a specific parent wasn't requested, then we assume they don't want results with status >= Page::statusUnsearchable
// if(strpos($selectorString, 'parent_id') === false) $selectorString .= ", status<" . Page::statusUnsearchable;
$caller = isset($options['caller']) ? $options['caller'] : 'pages.find';
$selectors = new Selectors($selectorString);
$pageFinder = $this->getPageFinder();
if ($debug) {
Debug::timer("{$caller}({$selectorString})", true);
}
$pagesInfo = $pageFinder->find($selectors, $options);
// note that we save this pagination state here and set it at the end of this method
// because it's possible that more find operations could be executed as the pages are loaded
$total = $pageFinder->getTotal();
$limit = $pageFinder->getLimit();
$start = $pageFinder->getStart();
if ($loadPages) {
// parent_id is null unless a single parent was specified in the selectors
$parent_id = $pageFinder->getParentID();
$idsSorted = array();
$idsByTemplate = array();
// organize the pages by template ID
foreach ($pagesInfo as $page) {
$tpl_id = $page['templates_id'];
if (!isset($idsByTemplate[$tpl_id])) {
$idsByTemplate[$tpl_id] = array();
}
$idsByTemplate[$tpl_id][] = $page['id'];
$idsSorted[] = $page['id'];
}
if (count($idsByTemplate) > 1) {
// perform a load for each template, which results in unsorted pages
$unsortedPages = new PageArray();
foreach ($idsByTemplate as $tpl_id => $ids) {
$opt = $loadOptions;
$opt['template'] = $this->templates->get($tpl_id);
$opt['parent_id'] = $parent_id;
$unsortedPages->import($this->getById($ids, $opt));
}
// put pages back in the order that the selectorEngine returned them in, while double checking that the selector matches
$pages = new PageArray();
foreach ($idsSorted as $id) {
foreach ($unsortedPages as $page) {
if ($page->id == $id) {
$pages->add($page);
break;
}
}
}
} else {
// there is only one template used, so no resorting is necessary
$pages = new PageArray();
reset($idsByTemplate);
$opt = $loadOptions;
$opt['template'] = $this->templates->get(key($idsByTemplate));
$opt['parent_id'] = $parent_id;
$pages->import($this->getById($idsSorted, $opt));
}
} else {
$pages = new PageArray();
}
$pages->setTotal($total);
$pages->setLimit($limit);
$pages->setStart($start);
$pages->setSelectors($selectors);
$pages->setTrackChanges(true);
if ($loadPages) {
$this->selectorCache($selectorString, $options, $pages);
}
if ($this->config->debug) {
$this->debugLog('find', $selectorString, $pages);
}
if ($debug) {
$count = $pages->count();
$note = ($count == $total ? $count : $count . "/{$total}") . " page(s)";
if ($count) {
$note .= ": " . $pages->first()->path;
if ($count > 1) {
$note .= " ... " . $pages->last()->path;
}
}
Debug::saveTimer("{$caller}({$selectorString})", $note);
}
if ($this->hasHook('found()')) {
$this->found($pages, array('pageFinder' => $pageFinder, 'pagesInfo' => $pagesInfo, 'options' => $options));
}
return $pages;
}
示例7: ___execute
/**
* Execute the process and return the resulting content generated by the process
*
* @return string
* @throws ProcessController404Exception
*
*/
public function ___execute()
{
$content = '';
$method = '';
$debug = $this->wire('config')->debug;
$breadcrumbs = $this->wire('breadcrumbs');
$headline = $this->wire('processHeadline');
$numBreadcrumbs = $breadcrumbs ? count($breadcrumbs) : null;
if ($process = $this->getProcess()) {
if ($method = $this->getProcessMethodName($this->process)) {
$className = $this->process->className();
if ($debug) {
Debug::timer("{$className}.{$method}()");
}
$content = $this->process->{$method}();
if ($debug) {
Debug::saveTimer("{$className}.{$method}()");
}
if ($method != 'execute') {
// some method other than the main one
if (!is_null($numBreadcrumbs) && $numBreadcrumbs === count($breadcrumbs)) {
// process added no breadcrumbs, but there should be more
if ($headline === $this->wire('processHeadline')) {
$process->headline(str_replace('execute', '', $method));
}
$moduleInfo = $this->wire('modules')->getModuleInfo($process);
$href = substr($this->wire('input')->url(), -1) == '/' ? '../' : './';
$process->breadcrumb($href, $moduleInfo['title']);
}
}
} else {
throw new ProcessController404Exception("Unrecognized path");
}
} else {
throw new ProcessController404Exception("The requested process does not exist");
}
if (empty($content) || is_bool($content)) {
$content = $this->process->getViewVars();
}
if (is_array($content)) {
// array of returned content indicates variables to send to a view
if (count($content)) {
$viewFile = $this->getViewFile($this->process, $method);
if ($viewFile) {
// get output from a separate view file
$template = new TemplateFile($viewFile);
foreach ($content as $key => $value) {
$template->set($key, $value);
}
$content = $template->render();
}
} else {
$content = '';
}
}
return $content;
}