本文整理汇总了PHP中Phalcon\Mvc\View::disableLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP View::disableLevel方法的具体用法?PHP View::disableLevel怎么用?PHP View::disableLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\View
的用法示例。
在下文中一共展示了View::disableLevel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* {@inheritdoc}
*/
public function render($params = array())
{
$currentViewsDir = $this->view->getViewsDir();
$this->view->setViewsDir($this->getServiceViewPath());
$this->view->disableLevel(View::LEVEL_LAYOUT);
$content = $this->view->getRender('services', $this->templateName, $params);
//rollback viewsDir
$this->view->setViewsDir($currentViewsDir);
return $content;
}
示例2: registerServices
/**
* Register the services here to make them general
* or register in the ModuleDefinition to make them module-specific
*/
public function registerServices(DiInterface $di)
{
//Read configuration
$config = (include __DIR__ . "/config/config.php");
// The URL component is used to generate all kind of urls in the application
$di->set('url', function () use($config) {
$url = new Url();
$url->setBaseUri($config->application->baseUri);
return $url;
});
//Registering a dispatcher
$di->set('dispatcher', function () {
//Create/Get an EventManager
$eventsManager = new EventsManager();
//Attach a listener
$eventsManager->attach('dispatch', function ($event, $dispatcher, $exception) {
//controller or action doesn't exist
if ($event->getType() == 'beforeException') {
switch ($exception->getCode()) {
case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
$dispatcher->forward(['module' => 'backend', 'controller' => 'errors', 'action' => 'notFound']);
return false;
}
}
});
$dispatcher = new Dispatcher();
$dispatcher->setDefaultNamespace("Phanbook\\Backend\\Controllers");
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
});
/**
* Setting up the view component
*/
$di->set('view', function () use($config) {
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->disableLevel([View::LEVEL_MAIN_LAYOUT => true, View::LEVEL_LAYOUT => true]);
$view->registerEngines(['.volt' => 'volt']);
// Create an event manager
$eventsManager = new EventsManager();
// Attach a listener for type 'view'
$eventsManager->attach('view', function ($event, $view) {
if ($event->getType() == 'notFoundView') {
throw new \Exception('View not found!!! (' . $view->getActiveRenderPath() . ')');
}
});
// Bind the eventsManager to the view component
$view->setEventsManager($eventsManager);
return $view;
});
$configMenu = (include __DIR__ . "/config/config.menu.php");
$di->setShared('menuStruct', function () use($configMenu) {
// if structure received from db table instead getting from $config
// we need to store it to cache for reducing db connections
$struct = $configMenu->get('menuStruct')->toArray();
return $struct;
});
}
示例3: registerServices
/**
* Register the services here to make them general
* or register in the ModuleDefinition to make them module-specific
*/
public function registerServices(DiInterface $di)
{
$di->set('view', function () {
$view = new View();
$view->setViewsDir(__DIR__ . '/views/');
$view->disableLevel([View::LEVEL_MAIN_LAYOUT => true, View::LEVEL_LAYOUT => true]);
$view->registerEngines(['.volt' => 'volt']);
// Create an event manager
$eventsManager = new EventsManager();
$eventsManager->attach('view', function ($event, $view) {
if ($event->getType() == 'notFoundView') {
throw new \Exception('View not found!!! (' . $view->getActiveRenderPath() . ')');
}
});
// Bind the eventsManager to the view component
$view->setEventsManager($eventsManager);
return $view;
});
}
示例4: registerServices
/**
* Register the services here to make them general or register in the ModuleDefinition to make them module-specific
*/
public function registerServices(\Phalcon\DiInterface $di)
{
/**
* Read configuration
*/
$config = (include __DIR__ . "/config/config.php");
/**
* Setting up the view component
*/
// The URL component is used to generate all kind of urls in the application
$di->set('url', function () {
$url = new Url();
$url->setBaseUri('/');
return $url;
});
/**
* Setting up the view component
*/
$di->set('view', function () use($config) {
$view = new View();
$view->setViewsDir($config->application->view->viewsDir);
$view->disableLevel([View::LEVEL_MAIN_LAYOUT => true, View::LEVEL_LAYOUT => true]);
$view->registerEngines(['.volt' => function () use($view, $config) {
$volt = new Volt($view);
$volt->setOptions(['compiledPath' => $config->application->view->compiledPath, 'compiledSeparator' => $config->application->view->compiledSeparator, 'compiledExtension' => $config->application->view->compiledExtension, 'compileAlways' => true]);
return $volt;
}]);
// Create an event manager
$eventsManager = new EventsManager();
// Attach a listener for type 'view'
$eventsManager->attach('view', function ($event, $view) {
if ($event->getType() == 'notFoundView') {
throw new \Exception('View not found!!! (' . $view->getActiveRenderPath() . ')');
}
});
// Bind the eventsManager to the view component
$view->setEventsManager($eventsManager);
return $view;
});
}
示例5: _getViewDisabled
protected function _getViewDisabled($level = null)
{
$view = new Phalcon\Mvc\View();
$view->setViewsDir('unit-tests/views/');
$view->setTemplateAfter('after');
$view->setTemplateBefore('before');
if ($level !== null) {
$view->disableLevel($level);
}
$view->start();
$view->render('test13', 'index');
$view->finish();
return $view;
}
示例6: view
protected function view()
{
$config = $this->_config;
$this->_di->set('view', function () use($config) {
$view = new View($config->toArray());
$view->setViewsDir($config->application->view->viewsDir);
$view->disableLevel([View::LEVEL_MAIN_LAYOUT => true, View::LEVEL_LAYOUT => true]);
$view->registerEngines(['.volt' => function () use($view, $config) {
$volt = new Volt($view);
$volt->setOptions(['compiledPath' => $config->application->view->compiledPath, 'compiledSeparator' => $config->application->view->compiledSeparator, 'compiledExtension' => $config->application->view->compiledExtension, 'compileAlways' => $config->application->debug]);
return $volt;
}]);
return $view;
});
}
示例7: function
$volt->setOptions(array("compiledPath" => COMPILED_VIEW_PATH, "compiledExtension" => ".php"));
return $volt;
});
$di->set('crypt', function () {
$crypt = new Crypt();
// 使用 blowfish
$crypt->setCipher('blowfish');
// 设置全局加密密钥
$crypt->setKey('blowfish');
return $crypt;
}, true);
// Setting up the view component
$di['view'] = function () {
$view = new View();
$view->setViewsDir('../app/views/');
$view->disableLevel(array(View::LEVEL_LAYOUT => true, View::LEVEL_MAIN_LAYOUT => true));
$view->registerEngines(array(".phtml" => 'voltService', ".volt" => 'voltService', ".json" => 'voltService'));
return $view;
};
// Setup a base URI so that all generated URIs include the "tutorial" folder
$di['url'] = function () {
$url = new Url();
$url->setBaseUri("/cgi/");
return $url;
};
// Setup the tag helpers
$di['tag'] = function () {
return new Tag();
};
// add routing capabilities
$di->set('router', function () {
示例8: function
$di->set('viewCache', function () use($di) {
$config = $di->get('config');
if ($config->application->debug) {
return new MemoryBackend(new FrontendNone());
} else {
// Cache data for one day by default
$frontCache = new FrontendOutput(['lifetime' => $config->cache->lifetime]);
return new FileCache($frontCache, ['cacheDir' => $config->cache->cacheDir, 'prefix' => $config->cache->prefix]);
}
});
// Setting up the view component
$di->set('view', function () use($di, $eventsManager) {
$config = $di->get('config');
$view = new View($config->toArray());
$view->setViewsDir($config->application->view->viewsDir);
$view->disableLevel([View::LEVEL_MAIN_LAYOUT => true, View::LEVEL_LAYOUT => true]);
$view->registerEngines(['.volt' => 'volt']);
// Attach a listener for type 'view'
$eventsManager->attach('view', function ($event, $view) {
if ($event->getType() == 'notFoundView') {
throw new \Exception('View not found!!! (' . $view->getActiveRenderPath() . ')');
}
});
// Bind the eventsManager to the view component
$view->setEventsManager($eventsManager);
return $view;
});
// Register the flash service with custom CSS classes
$di->set('flashSession', function () {
$flash = new Session(['error' => 'alert alert-danger', 'success' => 'alert alert-success', 'notice' => 'alert alert-info', 'warning' => 'alert alert-warning']);
return $flash;
示例9: _getViewDisabled
protected function _getViewDisabled($level = null)
{
$view = new View();
$view->setViewsDir(PATH_DATA . "views" . DIRECTORY_SEPARATOR);
$view->setTemplateAfter("after");
$view->setTemplateBefore("before");
if ($level !== null) {
$view->disableLevel($level);
}
$view->start();
$view->render("test13", "index");
$view->finish();
return $view;
}