本文整理汇总了PHP中Phalcon\Mvc\View::disable方法的典型用法代码示例。如果您正苦于以下问题:PHP View::disable方法的具体用法?PHP View::disable怎么用?PHP View::disable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\View
的用法示例。
在下文中一共展示了View::disable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setView
private function setView($manager)
{
/* ==================================================
* ตั้งค่าเรียกใช้งานไฟล์ View ทั้งหมด
* ================================================== */
$manager->set('view', function () {
$view = new View();
$view->disable();
return $view;
});
}
示例2: createFrom
/**
* @param array $config
* @param DiInterface $di
* @return MvcView
*/
public static function createFrom(array $config, DiInterface $di) : MvcView
{
$view = new MvcView();
if (isset($config['templatePath'])) {
$view->setViewsDir($config['templatePath']);
/** @var MvcDispatcher $dispatcher */
$dispatcher = $di->getShared('dispatcher');
$dispatcher->getEventsManager()->attach('dispatch', new self());
} else {
$view->disable();
}
return $view;
}
示例3: FactoryDefault
*/
$di = new FactoryDefault();
/**
* The URL component is used to generate all kind of urls in the application
*/
$di->setShared('url', function () use($config) {
$url = new UrlResolver();
$url->setBaseUri($config->application->baseUri);
return $url;
});
/**
* Setting up the view component
*/
$di->setShared('view', function () use($config) {
$view = new View();
$view->disable();
return $view;
});
/**
* If the configuration specify the use of metadata adapter use it or use memory otherwise
*/
$di->setShared('modelsMetadata', function () {
return new MetaDataAdapter();
});
$di->set('router', function () {
require __DIR__ . '/routes.php';
return $router;
});
$di->setShared('redis', function () use($config) {
$redis = new Redis();
$redis->connect($config->redis->host, $config->redis->port);
示例4: registerServices
//.........这里部分代码省略.........
$di->getVersionLoader()->load();
});
$oApiDispatcherEventsManager->attach('dispatch', function (Event $oEvent, Dispatcher $oDispatcher, $data) {
/**
* @type \DiCustom $di
*/
$di = Di::getDefault();
$oLogger = $di->getFileLogger();
// $oRouter = $di->getRouter();
//
// $arParams = $oRouter->getParams();
//
// $oLogger->debug(__CLASS__ . ': ' . $oEvent->getType() . ': trying to dispatch: from router: '
// . ' module: ' . $oRouter->getModuleName()
// . ' media: ' . $arParams['media']
// . ' version: v' . $arParams['major'] . '_' . $arParams['minor']
// . ' controller: ' . $oRouter->getControllerName()
// . ' action: ' . $oRouter->getActionName()
// );
$arParams = $oDispatcher->getParams();
$oLogger->debug(__CLASS__ . ': ' . $oEvent->getType() . ': trying to dispatch: from dispatcher: ' . ' module: ' . $oDispatcher->getModuleName() . ' media: ' . $arParams['media'] . ' version: v' . $arParams['major'] . '_' . $arParams['minor'] . ' controller: ' . $oDispatcher->getControllerName() . ' action: ' . $oDispatcher->getActionName());
// $oLogger->debug(__CLASS__ . ': ' . $oEvent->getType());
});
$oDispatcher->setEventsManager($oApiDispatcherEventsManager);
$di->setShared('dispatcher', $oDispatcher);
// $di->set('dispatcher', function() use($di){
// $dispatcher = new Dispatcher();
// $oApiDispatcherEventsManager = new Manager();
// $oLogger = $di->getFileLogger();
// $oRouter = $di->getRouter();
// $oRequest = $di->getRequest();
//
// $oLogger->debug('api module ' . __FUNCTION__ . ': setting up dispatcher');
//
// $oApiDispatcherEventsManager->attach('dispatch', function(Event $event, Dispatcher $dispatcher, $data) use($oLogger, $oRouter, $oRequest){
//
// if($event->getType() == 'beforeDispatchLoop'){
//
// $arRoutes = $oRouter->getRoutes();
//
// foreach ($arRoutes as $oRoute) {
// $oRoute->beforeMatch(function($uri, $route) use ($oLogger){
// $oLogger->debug('__ api module dispatcher route beforeMatch: ' . $uri . $route);
//
// });
// $oLogger->debug('api module dispatcher: ' . $event->getType() . ': route registered: ' . $oRoute->getCompiledPattern());
//
// $regPattern = $oRoute->getCompiledPattern();
//
// $strUri = $oRequest->getURI();
//
// if(preg_match($regPattern, $strUri)){
// $oLogger->debug('"' . $strUri . '" matched ' . $regPattern);
// }else{
// $oLogger->debug('"' . $strUri . '" mismatched ' . $regPattern);
// }
//
// }
//
// }
//
// $oLogger->debug('api dispatcher: ' . $event->getType() . ': route matched: ' . print_r($oRouter->getMatchedRoute(), true));
// $oLogger->debug('api dispatcher: ' . $event->getType()
// . ' module "' . $oRouter->getModuleName()
// . '" controller: "' . $oRouter->getControllerName()
// . '" action: "' . $oRouter->getActionName() . '"'
// );
// });
//
// $dispatcher->setEventsManager($oApiDispatcherEventsManager);
// $dispatcher->setDefaultNamespace('App\Modules\Api\Web');
// return $dispatcher;
// });
//
//
//
// $oConfig = new Config(array(
// 'application' => array(
// 'viewsDir' => __DIR__ . '/views',
// 'cacheDir' => __DIR__ . '/../../../var/cache/regular'
// ),
// ));
//
// $di->get('config')->merge($oConfig);
/**
* Setting up the view component
*/
$di->set('view', function () use($oLogger) {
$oView = new View();
$oView->setRenderLevel(View::LEVEL_NO_RENDER);
$oView->disable();
$oLogger->debug('view: render level set to disabled');
//Disable several levels
// $view->disableLevel(array(
// View::LEVEL_LAYOUT => true,
// View::LEVEL_MAIN_LAYOUT => true
// ));
return $oView;
}, true);
}