本文整理汇总了PHP中Nette\Debug::addPanel方法的典型用法代码示例。如果您正苦于以下问题:PHP Debug::addPanel方法的具体用法?PHP Debug::addPanel怎么用?PHP Debug::addPanel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Debug
的用法示例。
在下文中一共展示了Debug::addPanel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($dsn, $username = NULL, $password = NULL, array $options = NULL)
{
parent::__construct($dsn, $username, $password, $options);
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('Nette\\Database\\Statement', array($this)));
$class = 'Nette\\Database\\Drivers\\Pdo' . $this->getAttribute(PDO::ATTR_DRIVER_NAME) . 'Driver';
if (class_exists($class)) {
$this->driver = new $class($this, (array) $options);
}
$this->preprocessor = new SqlPreprocessor($this);
$this->databaseReflection = new Nette\Database\Reflection\DatabaseReflection();
// TODO
if (!Nette\Debug::$productionMode) {
Nette\Debug::addPanel($panel = new DatabasePanel($dsn));
$this->onQuery[] = callback($panel, 'logQuery');
}
}
示例2: register
/**
* Registeres panel to Debug bar
*/
public static function register()
{
Debug::addPanel(new self());
}
示例3: run
/**
* Dispatch a HTTP request to a front controller.
* @return void
*/
public function run()
{
$httpRequest = $this->getHttpRequest();
$httpResponse = $this->getHttpResponse();
// check HTTP method
if ($this->allowedMethods) {
$method = $httpRequest->getMethod();
if (!in_array($method, $this->allowedMethods, TRUE)) {
$httpResponse->setCode(Nette\Web\IHttpResponse::S501_NOT_IMPLEMENTED);
$httpResponse->setHeader('Allow', implode(',', $this->allowedMethods));
echo '<h1>Method ' . htmlSpecialChars($method) . ' is not implemented</h1>';
return;
}
}
// dispatching
$request = NULL;
$repeatedError = FALSE;
do {
try {
if (count($this->requests) > self::$maxLoop) {
throw new ApplicationException('Too many loops detected in application life cycle.');
}
if (!$request) {
$this->onStartup($this);
// autostarts session
$session = $this->getSession();
if (!$session->isStarted() && $session->exists()) {
$session->start();
}
// routing
$router = $this->getRouter();
// enable routing debuggger
Nette\Debug::addPanel(new RoutingDebugger($router, $httpRequest));
$request = $router->match($httpRequest);
if (!$request instanceof PresenterRequest) {
$request = NULL;
throw new BadRequestException('No route for HTTP request.');
}
if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
throw new BadRequestException('Invalid request. Presenter is not achievable.');
}
}
$this->requests[] = $request;
$this->onRequest($this, $request);
// Instantiate presenter
$presenter = $request->getPresenterName();
try {
$class = $this->getPresenterLoader()->getPresenterClass($presenter);
$request->setPresenterName($presenter);
} catch (InvalidPresenterException $e) {
throw new BadRequestException($e->getMessage(), 404, $e);
}
$request->freeze();
// Execute presenter
$this->presenter = new $class;
$response = $this->presenter->run($request);
$this->onResponse($this, $response);
// Send response
if ($response instanceof ForwardingResponse) {
$request = $response->getRequest();
continue;
} elseif ($response instanceof IPresenterResponse) {
$response->send();
}
break;
} catch (\Exception $e) {
// fault barrier
$this->onError($this, $e);
if (!$this->catchExceptions) {
$this->onShutdown($this, $e);
throw $e;
}
if ($repeatedError) {
$e = new ApplicationException('An error occured while executing error-presenter', 0, $e);
}
if (!$httpResponse->isSent()) {
$httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
}
//.........这里部分代码省略.........
示例4: run
/**
* Dispatch a HTTP request to a front controller.
* @return void
*/
public function run()
{
$httpRequest = $this->getHttpRequest();
$httpResponse = $this->getHttpResponse();
// check HTTP method
if ($this->allowedMethods) {
$method = $httpRequest->getMethod();
if (!in_array($method, $this->allowedMethods, TRUE)) {
$httpResponse->setCode(Nette\Web\IHttpResponse::S501_NOT_IMPLEMENTED);
$httpResponse->setHeader('Allow', implode(',', $this->allowedMethods));
echo '<h1>Method ' . htmlSpecialChars($method) . ' is not implemented</h1>';
return;
}
}
// dispatching
$request = NULL;
$repeatedError = FALSE;
do {
try {
if (count($this->requests) > self::$maxLoop) {
throw new ApplicationException('Too many loops detected in application life cycle.');
}
if (!$request) {
$this->onStartup($this);
// autostarts session
$session = $this->getSession();
if (!$session->isStarted() && $session->exists()) {
$session->start();
}
// routing
$router = $this->getRouter();
// enable routing debuggger
Nette\Debug::addPanel(new RoutingDebugger($router, $httpRequest));
$request = $router->match($httpRequest);
if (!$request instanceof PresenterRequest) {
$request = NULL;
throw new BadRequestException('No route for HTTP request.');
}
if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
throw new BadRequestException('Invalid request. Presenter is not achievable.');
}
}
$this->requests[] = $request;
$this->onRequest($this, $request);
// Instantiate presenter
$presenterName = $request->getPresenterName();
try {
$this->presenter = $this->getPresenterFactory()->createPresenter($presenterName);
} catch (InvalidPresenterException $e) {
throw new BadRequestException($e->getMessage(), 404, $e);
}
$this->getPresenterFactory()->getPresenterClass($presenterName);
$request->setPresenterName($presenterName);
$request->freeze();
// Execute presenter
$response = $this->presenter->run($request);
$this->onResponse($this, $response);
// Send response
if ($response instanceof ForwardingResponse) {
$request = $response->getRequest();
continue;
} elseif ($response instanceof IPresenterResponse) {
$response->send($httpRequest, $httpResponse);
}
break;
} catch (\Exception $e) {
// fault barrier
$this->onError($this, $e);
if (!$this->catchExceptions) {
$this->onShutdown($this, $e);
throw $e;
}
if ($repeatedError) {
$e = new ApplicationException('An error occured while executing error-presenter', 0, $e);
}
if (!$httpResponse->isSent()) {
$httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
}
//.........这里部分代码省略.........
示例5: getAndRegister
/**
* Register Doctrine 2 Panel
*/
public static function getAndRegister()
{
$panel = new static();
\Nette\Debug::addPanel($panel);
return $panel;
}
示例6: run
/**
* Dispatch a HTTP request to a front controller.
* @return void
*/
public function run()
{
$httpRequest = $this->getHttpRequest();
$httpResponse = $this->getHttpResponse();
$httpRequest->setEncoding('UTF-8');
if (Environment::getVariable('baseUri') === NULL) {
Environment::setVariable('baseUri', $httpRequest->getUri()->getBasePath());
}
// autostarts session
$session = $this->getSession();
if (!$session->isStarted() && $session->exists()) {
$session->start();
}
// enable routing debuggger
Nette\Debug::addPanel(new RoutingDebugger($this->getRouter(), $httpRequest));
// check HTTP method
if ($this->allowedMethods) {
$method = $httpRequest->getMethod();
if (!in_array($method, $this->allowedMethods, TRUE)) {
$httpResponse->setCode(Nette\Web\IHttpResponse::S501_NOT_IMPLEMENTED);
$httpResponse->setHeader('Allow', implode(',', $this->allowedMethods));
echo '<h1>Method ' . htmlSpecialChars($method) . ' is not implemented</h1>';
return;
}
}
// dispatching
$request = NULL;
$repeatedError = FALSE;
do {
try {
if (count($this->requests) > self::$maxLoop) {
throw new ApplicationException('Too many loops detected in application life cycle.');
}
if (!$request) {
$this->onStartup($this);
// default router
$router = $this->getRouter();
if ($router instanceof MultiRouter && !count($router)) {
$router[] = new SimpleRouter(array('presenter' => 'Default', 'action' => 'default'));
}
// routing
$request = $router->match($httpRequest);
if (!$request instanceof PresenterRequest) {
$request = NULL;
throw new BadRequestException('No route for HTTP request.');
}
if (strcasecmp($request->getPresenterName(), $this->errorPresenter) === 0) {
throw new BadRequestException('Invalid request.');
}
}
$this->requests[] = $request;
$this->onRequest($this, $request);
// Instantiate presenter
$presenter = $request->getPresenterName();
try {
$class = $this->getPresenterLoader()->getPresenterClass($presenter);
$request->setPresenterName($presenter);
} catch (InvalidPresenterException $e) {
throw new BadRequestException($e->getMessage(), 404, $e);
}
$request->freeze();
// Execute presenter
$this->presenter = new $class();
$response = $this->presenter->run($request);
// Send response
if ($response instanceof ForwardingResponse) {
$request = $response->getRequest();
continue;
} elseif ($response instanceof IPresenterResponse) {
$response->send();
}
break;
} catch (\Exception $e) {
// fault barrier
if ($this->catchExceptions === NULL) {
$this->catchExceptions = Environment::isProduction();
}
$this->onError($this, $e);
if (!$this->catchExceptions) {
$this->onShutdown($this, $e);
throw $e;
}
if ($repeatedError) {
$e = new ApplicationException('An error occured while executing error-presenter', 0, $e);
}
if (!$httpResponse->isSent()) {
$httpResponse->setCode($e instanceof BadRequestException ? $e->getCode() : 500);
}
if (!$repeatedError && $this->errorPresenter) {
$repeatedError = TRUE;
$request = new PresenterRequest($this->errorPresenter, PresenterRequest::FORWARD, array('exception' => $e));
// continue
} else {
// default error handler
echo "<!DOCTYPE html><meta name=robots content=noindex>\n\n";
echo "<style>body{color:black;background:white;width:500px;margin:100px auto}h1{font:bold 47px/1.5 sans-serif;margin:.6em 0}p{font:21px/1.5 Georgia,serif;margin:1.5em 0}small{font-size:70%;color:gray}</style>\n\n";
//.........这里部分代码省略.........