當前位置: 首頁>>代碼示例>>PHP>>正文


PHP AppKernel::isDebug方法代碼示例

本文整理匯總了PHP中AppKernel::isDebug方法的典型用法代碼示例。如果您正苦於以下問題:PHP AppKernel::isDebug方法的具體用法?PHP AppKernel::isDebug怎麽用?PHP AppKernel::isDebug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AppKernel的用法示例。


在下文中一共展示了AppKernel::isDebug方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onKernelRequest

 /**
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     $route = $request->attributes->get('_route');
     if (empty($route)) {
         $route = $request->attributes->get('_master_request_route');
     }
     if (!$this->provider->isItemWhitelisted($route)) {
         $notFoundException = new NotFoundHttpException('Sorry, the page that you requested was not found.');
         $statusCode = $notFoundException->getStatusCode();
         $parameters = ['status_code' => $statusCode, 'status_text' => Response::$statusTexts[$statusCode], 'currentContent' => '', 'exception' => FlattenException::create($notFoundException), 'logger' => $this->logger];
         $view = View::create($parameters);
         $view->setFormat(self::VIEW_FORMAT);
         $view->setTemplate($this->findTemplate($request, $statusCode, $this->kernel->isDebug()));
         $response = $this->viewHandler->handle($view);
         $event->setResponse($response);
     }
 }
開發者ID:gitter-badger,項目名稱:diamantedesk-application,代碼行數:21,代碼來源:OroApiCallRestrictionListener.php

示例2: setServiceKernel

 /**
  * 每個testXXX執行之前,都會執行此函數,淨化數據庫。
  * 
  * NOTE: 如果數據庫已創建,那麽執行清表操作,不重建。
  */
 private function setServiceKernel()
 {
     $kernel = new \AppKernel('test', false);
     $kernel->loadClassCache();
     $kernel->boot();
     Request::enableHttpMethodParameterOverride();
     $request = Request::createFromGlobals();
     $serviceKernel = ServiceKernel::create($kernel->getEnvironment(), $kernel->isDebug());
     $serviceKernel->setParameterBag($kernel->getContainer()->getParameterBag());
     $serviceKernel->setConnection($kernel->getContainer()->get('database_connection'));
     $currentUser = new CurrentUser();
     $currentUser->fromArray(array('id' => 1, 'nickname' => 'admin', 'email' => 'admin@admin.com', 'password' => 'admin', 'currentIp' => '127.0.0.1', 'roles' => array('ROLE_USER', 'ROLE_ADMIN', 'ROLE_SUPER_ADMIN', 'ROLE_TEACHER')));
     $serviceKernel->setCurrentUser($currentUser);
     $this->serviceKernel = $serviceKernel;
 }
開發者ID:styling,項目名稱:LeesPharm,代碼行數:20,代碼來源:BaseTestCase.php

示例3: AppKernel

}
use Symfony\Component\Debug\Debug;
use Topxia\Service\User\CurrentUser;
use Topxia\Service\Common\ServiceKernel;
use Symfony\Component\HttpFoundation\Request;
fix_gpc_magic();
$loader = (require_once __DIR__ . '/../app/bootstrap.php.cache');
Debug::enable();
require_once __DIR__ . '/../app/AppKernel.php';
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
Request::enableHttpMethodParameterOverride();
$request = Request::createFromGlobals();
$kernel->boot();
// START: init service kernel
$serviceKernel = ServiceKernel::create($kernel->getEnvironment(), $kernel->isDebug());
$serviceKernel->setEnvVariable(array('host' => $request->getHttpHost(), 'schemeAndHost' => $request->getSchemeAndHttpHost(), 'basePath' => $request->getBasePath(), 'baseUrl' => $request->getSchemeAndHttpHost() . $request->getBasePath()));
$serviceKernel->setParameterBag($kernel->getContainer()->getParameterBag());
$serviceKernel->registerModuleDirectory(dirname(__DIR__) . '/plugins');
$serviceKernel->setConnection($kernel->getContainer()->get('database_connection'));
$serviceKernel->getConnection()->exec('SET NAMES UTF8');
$currentUser = new CurrentUser();
$currentUser->fromArray(array('id' => 0, 'nickname' => '遊客', 'currentIp' => $request->getClientIp(), 'roles' => array()));
$serviceKernel->setCurrentUser($currentUser);
// END: init service kernel
// NOTICE: 防止請求捕捉失敗而做異常處理
// 包括:數據庫連接失敗等
try {
    $response = $kernel->handle($request);
} catch (\RuntimeException $e) {
    echo "Error!  " . $e->getMessage();
開發者ID:robert-li-2015,項目名稱:EduSoho,代碼行數:31,代碼來源:app_dev.php


注:本文中的AppKernel::isDebug方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。