本文整理汇总了PHP中dm::createContext方法的典型用法代码示例。如果您正苦于以下问题:PHP dm::createContext方法的具体用法?PHP dm::createContext怎么用?PHP dm::createContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dm
的用法示例。
在下文中一共展示了dm::createContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getContext
/**
* Diem override:
* sfContext is hardcoded in symfony unit tests.
* Replace it with dmContext.
*
* @see sfBrowser
*/
public function getContext($forceReload = false)
{
if (null === $this->context || $forceReload) {
$isContextEmpty = null === $this->context;
$context = $isContextEmpty ? sfContext::getInstance() : $this->context;
// create configuration
$currentConfiguration = $context->getConfiguration();
$configuration = ProjectConfiguration::getApplicationConfiguration($currentConfiguration->getApplication(), $currentConfiguration->getEnvironment(), $currentConfiguration->isDebug());
// connect listeners
$configuration->getEventDispatcher()->connect('application.throw_exception', array($this, 'listenToException'));
foreach ($this->listeners as $name => $listener) {
$configuration->getEventDispatcher()->connect($name, $listener);
}
// create context
$this->context = dm::createContext($configuration);
unset($currentConfiguration);
if (!$isContextEmpty) {
sfConfig::clear();
sfConfig::add($this->rawConfiguration);
} else {
$this->rawConfiguration = sfConfig::getAll();
}
}
return $this->context;
}
示例2: boot
protected function boot()
{
$configuration = ProjectConfiguration::getApplicationConfiguration($this->options['app'], $this->options['env'], $this->options['debug']);
$this->context = dm::createContext($configuration);
sfConfig::set('sf_logging_enabled', false);
// remove all cache
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));
}
示例3: getContext
public function getContext()
{
if (null === $this->context) {
if (!dmContext::hasInstance()) {
$this->logSection('diem', sprintf('Loading %s...', get_class($this->configuration)));
dm::createContext($this->configuration);
}
$this->context = dmContext::getInstance();
}
return $this->context;
}
示例4: getContext
/**
* Get the current context
* @return dmContext
*/
public function getContext()
{
if (null === $this->context) {
if (!dmContext::hasInstance()) {
$this->logSection('Diem Extended', sprintf('Loading %s...', get_class($this->configuration)));
dm::createContext($this->configuration);
}
$this->context = dmContext::getInstance();
$this->context->get('filesystem')->setFormatter($this->formatter);
}
return $this->context;
}
示例5: dirname
<?php
require_once dirname(__FILE__) . '/../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration('front', 'prod', false);
dm::createContext($configuration)->dispatch();
示例6: debug_backtrace
<?php
// guess current application
if (!isset($app)) {
$traces = debug_backtrace();
$caller = $traces[0];
$dirPieces = explode(DIRECTORY_SEPARATOR, dirname($caller['file']));
$app = array_pop($dirPieces);
}
require_once dirname(__FILE__) . '/../../config/ProjectConfiguration.class.php';
$configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', isset($debug) ? $debug : true);
dm::createContext($configuration);
// remove all cache
sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir'));