本文整理汇总了PHP中Icinga\Application\Icinga::setApp方法的典型用法代码示例。如果您正苦于以下问题:PHP Icinga::setApp方法的具体用法?PHP Icinga::setApp怎么用?PHP Icinga::setApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Icinga\Application\Icinga
的用法示例。
在下文中一共展示了Icinga::setApp方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param string $baseDir Icinga Web 2 base directory
* @param string $configDir Path to Icinga Web 2's configuration files
*/
protected function __construct($baseDir = null, $configDir = null)
{
if ($baseDir === null) {
$baseDir = dirname($this->getBootstrapDirectory());
}
$this->baseDir = $baseDir;
$this->appDir = $baseDir . '/application';
$this->vendorDir = $baseDir . '/library/vendor';
$this->libDir = realpath(__DIR__ . '/../..');
$this->setupAutoloader();
if ($configDir === null) {
$configDir = getenv('ICINGAWEB_CONFIGDIR');
if ($configDir === false) {
$configDir = Platform::isWindows() ? $baseDir . '/config' : '/etc/icingaweb2';
}
}
$canonical = realpath($configDir);
$this->configDir = $canonical ? $canonical : $configDir;
set_include_path(implode(PATH_SEPARATOR, array($this->vendorDir, get_include_path())));
Benchmark::measure('Bootstrap, autoloader registered');
Icinga::setApp($this);
require_once dirname(__FILE__) . '/functions.php';
}
示例2: setupIcingaMock
/**
* Setup mock object for the application's bootstrap
*
* @param Zend_Controller_Request_Abstract $request The request to be returned by
* Icinga::app()->getFrontController()->getRequest()
*/
protected function setupIcingaMock(Zend_Controller_Request_Abstract $request)
{
$bootstrapMock = Mockery::mock('Icinga\\Application\\ApplicationBootstrap')->shouldDeferMissing();
$bootstrapMock->shouldReceive('getFrontController->getRequest')->andReturnUsing(function () use($request) {
return $request;
})->shouldReceive('getApplicationDir')->andReturn(self::$appDir);
Icinga::setApp($bootstrapMock, true);
}
示例3: setupIcingaMock
/**
* Setup mock object for the application's bootstrap
*
* @return Mockery\Mock
*/
protected function setupIcingaMock()
{
$requestMock = Mockery::mock('Icinga\\Web\\Request')->shouldDeferMissing();
$requestMock->shouldReceive('getPathInfo')->andReturn('')->byDefault()->shouldReceive('getBaseUrl')->andReturn('/')->byDefault()->shouldReceive('getQuery')->andReturn(array())->byDefault()->shouldReceive('getParam')->with(Mockery::type('string'), Mockery::type('string'))->andReturnUsing(function ($name, $default) {
return $default;
})->byDefault();
$responseMock = Mockery::mock('Icinga\\Web\\Response')->shouldDeferMissing();
// Can't express this as demeter chains. See: https://github.com/padraic/mockery/issues/59
$bootstrapMock = Mockery::mock('Icinga\\Application\\ApplicationBootstrap')->shouldDeferMissing();
$libDir = dirname(self::$libDir);
$bootstrapMock->shouldReceive('getFrontController')->andReturn($bootstrapMock)->shouldReceive('getApplicationDir')->andReturn(self::$appDir)->shouldReceive('getLibraryDir')->andReturnUsing(function ($subdir = null) use($libDir) {
if ($subdir !== null) {
$libDir .= '/' . ltrim($subdir, '/');
}
return $libDir;
})->shouldReceive('getRequest')->andReturn($requestMock)->shouldReceive('getResponse')->andReturn($responseMock);
Icinga::setApp($bootstrapMock, true);
return $bootstrapMock;
}
示例4: __construct
/**
* Constructor
*/
protected function __construct($configDir = null)
{
$this->libDir = realpath(__DIR__ . '/../..');
if (!defined('ICINGA_LIBDIR')) {
define('ICINGA_LIBDIR', $this->libDir);
}
if (defined('ICINGAWEB_APPDIR')) {
$this->appDir = ICINGAWEB_APPDIR;
} elseif (array_key_exists('ICINGAWEB_APPDIR', $_SERVER)) {
$this->appDir = $_SERVER['ICINGAWEB_APPDIR'];
} else {
$this->appDir = realpath($this->libDir . '/../application');
}
if (!defined('ICINGAWEB_APPDIR')) {
define('ICINGAWEB_APPDIR', $this->appDir);
}
if ($configDir === null) {
if (array_key_exists('ICINGAWEB_CONFIGDIR', $_SERVER)) {
$configDir = $_SERVER['ICINGAWEB_CONFIGDIR'];
} else {
$configDir = '/etc/icingaweb';
}
}
$this->configDir = realpath($configDir);
$this->setupAutoloader();
$this->setupZendAutoloader();
Benchmark::measure('Bootstrap, autoloader registered');
Icinga::setApp($this);
require_once dirname(__FILE__) . '/functions.php';
}