本文整理汇总了PHP中Kwf_Setup::getConfigSection方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwf_Setup::getConfigSection方法的具体用法?PHP Kwf_Setup::getConfigSection怎么用?PHP Kwf_Setup::getConfigSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kwf_Setup
的用法示例。
在下文中一共展示了Kwf_Setup::getConfigSection方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _clearCache
protected function _clearCache($options)
{
$url = Kwf_Config::getValue('assetsCacheUrl') . '?web=' . Kwf_Config::getValue('application.id') . '§ion=' . Kwf_Setup::getConfigSection() . '&clear';
try {
$out = file_get_contents($url);
$this->_output("cleared: assetsServer [" . $out . "]\n");
} catch (Exception $e) {
$this->_output("cleared: assetsServer [ERROR] " . $e->getMessage() . "\n");
}
}
示例2: __construct
public function __construct($config = array())
{
if (isset($config['prefix'])) {
$this->_prefix = $config['prefix'];
} else {
$this->_prefix = Zend_Registry::get('config')->application->id . '-' . Kwf_Setup::getConfigSection() . '-bench-';
}
if (isset($config['memcache'])) {
$this->_memcache = $config['memcache'];
}
}
示例3: reload
public static function reload()
{
$configClass = Kwf_Setup::$configClass;
$config = new $configClass(Kwf_Setup::getConfigSection());
$cacheId = 'config_' . str_replace('-', '_', Kwf_Setup::getConfigSection());
Kwf_Config_Cache::getInstance()->save($config, $cacheId);
if (extension_loaded('apc')) {
$apcCacheId = $cacheId . getcwd();
apc_delete($apcCacheId);
apc_delete($apcCacheId . 'mtime');
}
Kwf_Config_Web::clearInstances();
Kwf_Registry::set('config', $config);
}
示例4: image
public function image($image, $alt = '', $attributes = null)
{
if (!$image) {
return '';
}
$url = $this->_getImageUrl($image);
if ($url == '') {
return '';
}
if (Kwf_Config::getValue('assetsCacheUrl') && substr($url, 0, 8) == '/assets/') {
$url = Kwf_Config::getValue('assetsCacheUrl') . '?web=' . Kwf_Config::getValue('application.id') . '§ion=' . Kwf_Setup::getConfigSection() . '&url=' . substr($url, 1);
} else {
if (Kwf_Setup::getBaseUrl() && substr($url, 0, 8) == '/assets/') {
$url = Kwf_Setup::getBaseUrl() . $url;
}
}
$class = '';
if (is_string($attributes)) {
$class = $attributes;
}
if (is_string($image)) {
if (file_exists(str_replace('/images/', '/images/dpr2/', $this->_getAssetPath($image)))) {
$class .= ' kwfReplaceImageDpr2';
}
}
$class = trim($class);
if (!is_array($attributes)) {
$attributes = array();
}
if ($class != '') {
$attributes['class'] = $class;
}
$size = $this->_getImageSize($image);
if (!isset($attributes['width'])) {
$attributes['width'] = $size['width'];
}
if (!isset($attributes['height'])) {
$attributes['height'] = $size['height'];
}
$attr = '';
foreach ($attributes as $k => $i) {
$attr .= ' ' . $k . '="' . $i . '"';
}
return "<img src=\"{$url}\"{$attr} alt=\"{$alt}\" />";
}
示例5: reload
public static function reload()
{
$configClass = Kwf_Setup::$configClass;
$config = new $configClass(Kwf_Setup::getConfigSection());
$cacheId = 'config_' . str_replace(array('-', '.'), '_', Kwf_Setup::getConfigSection());
Kwf_Config_Cache::getInstance()->save($config, $cacheId);
if (extension_loaded('apc')) {
$apcCacheId = $cacheId . getcwd();
apc_delete($apcCacheId);
apc_delete($apcCacheId . 'mtime');
if (PHP_SAPI == 'cli') {
Kwf_Util_Apc::callClearCacheByCli(array(array('cacheIds' => $apcCacheId . ',' . $apcCacheId . 'mtime')));
}
Kwf_Cache_SimpleStatic::clear('config-');
}
Kwf_Config_Web::clearInstances();
Kwf_Registry::set('config', $config);
}
示例6: getOther
public static function getOther()
{
$ec2 = new Kwf_Util_Aws_Ec2();
$r = $ec2->describe_instances(array('Filter' => array(array('Name' => 'tag:application.id', 'Value' => Kwf_Config::getValue('application.id')), array('Name' => 'tag:config_section', 'Value' => Kwf_Setup::getConfigSection()))));
if (!$r->isOK()) {
throw new Kwf_Exception($r->body->asXml());
}
$ownHostname = file_get_contents('http://169.254.169.254/latest/meta-data/public-hostname');
$domains = array();
foreach ($r->body->reservationSet->item as $resItem) {
foreach ($resItem->instancesSet->item as $item) {
$dnsName = (string) $item->dnsName;
if ($dnsName && $dnsName != $ownHostname) {
$domains[] = $dnsName;
}
}
}
return array_unique($domains);
}
示例7: setUp
protected function setUp()
{
if (!($cfg = Kwf_Registry::get('testServerConfig'))) {
throw new Kwf_Exception("testServerConfig not set");
}
Kwf_Util_Apc::callClearCacheByCli(array('type' => 'user'));
Kwf_Cache::factory('Core', 'Memcached', array('lifetime' => null, 'automatic_cleaning_factor' => false, 'automatic_serialization' => true))->clean();
$d = $this->_domain;
if (!$d) {
$domain = $cfg->server->domain;
} else {
if (!isset($cfg->kwc->domains->{$d})) {
throw new Kwf_Exception("Domain '{$d}' not found in config");
}
$domain = $cfg->kwc->domains->{$d}->domain;
}
$this->setBrowserUrl('http://' . $domain . '/');
$this->_unitTestCookie = md5(uniqid('testId', true));
$this->captureScreenshotOnFailure = Kwf_Setup::getConfigSection() == 'vivid-test-server';
$this->screenshotPath = '/mnt/screenshots';
$this->screenshotUrl = 'http://screenshots.vivid';
parent::setUp();
}
示例8: _getCacheIdPrefix
protected function _getCacheIdPrefix()
{
static $cacheIdPrefix;
if (!isset($cacheIdPrefix)) {
$cacheIdPrefix = Kwf_Config::getValue('application.id');
if (!$cacheIdPrefix) {
throw new Kwf_Exception("application.id has to be set in config");
}
$cacheIdPrefix .= Kwf_Setup::getConfigSection();
}
return $cacheIdPrefix;
}
示例9: getUniquePrefix
public static function getUniquePrefix()
{
static $ret;
if (!isset($ret)) {
$ret = getcwd() . '-' . Kwf_Setup::getConfigSection() . '-';
}
return $ret;
}
示例10: callUtil
public static function callUtil($method, $params, $options = array())
{
$outputType = '';
if (isset($params['type']) && $params['type'] == 'user') {
$outputType = 'apc user';
} else {
if (isset($params['type']) && $params['type'] == 'file') {
$outputType = 'optcode';
}
}
$params['password'] = self::_getHttpPassword();
$skipOtherServers = isset($options['skipOtherServers']) ? $options['skipOtherServers'] : false;
$config = Kwf_Registry::get('config');
if (!$config->server->aws || $skipOtherServers) {
$d = $config->server->domain;
if (!$d) {
if (isset($options['outputFn'])) {
call_user_func($options['outputFn'], "error: {$outputType}: domain not set");
}
return false;
}
$domains = array(array('domain' => $d));
if ($config->server->noRedirectPattern) {
$domains[0]['alternative'] = str_replace(array('^', '\\', '$'), '', $config->server->noRedirectPattern);
}
} else {
$ec2 = new Kwf_Util_Aws_Ec2();
$r = $ec2->describe_instances(array('Filter' => array(array('Name' => 'tag:application.id', 'Value' => $config->application->id), array('Name' => 'tag:config_section', 'Value' => Kwf_Setup::getConfigSection()))));
if (!$r->isOK()) {
throw new Kwf_Exception($r->body->asXml());
}
$domains = array();
foreach ($r->body->reservationSet->item as $resItem) {
foreach ($resItem->instancesSet->item as $item) {
$dnsName = (string) $item->dnsName;
if ($dnsName) {
$domains[] = array('domain' => $dnsName);
}
}
}
}
foreach ($domains as $d) {
$s = microtime(true);
$urlPart = "http://";
$baseUrl = Kwf_Setup::getBaseUrl();
$url = "{$urlPart}{$d['domain']}{$baseUrl}/kwf/util/apc/{$method}";
$client = new Zend_Http_Client();
$client->setMethod(Zend_Http_Client::POST);
$client->setParameterPost($params);
$client->setConfig(array('timeout' => 60, 'keepalive' => true));
$client->setUri($url);
$body = null;
$outputMessage = 'could not reach web per http';
try {
$response = $client->request();
$result = !$response->isError() && substr($response->getBody(), 0, 2) == 'OK';
$body = $response->getBody();
$outputMessage = $body;
} catch (Exception $e) {
$result = false;
}
$url2 = null;
if (!$result && isset($d['alternative'])) {
$url2 = "{$urlPart}{$d['alternative']}{$baseUrl}/kwf/util/apc/{$method}";
$client = new Zend_Http_Client();
$client->setMethod(Zend_Http_Client::POST);
$client->setConfig(array('timeout' => 60, 'keepalive' => true));
$client->setUri($url2);
$client->setParameterPost($params);
try {
$response = $client->request();
$result = !$response->isError() && substr($response->getBody(), 0, 2) == 'OK';
$body = $response->getBody();
$outputMessage = $body;
} catch (Exception $e) {
$result = false;
}
}
if (isset($options['outputFn'])) {
$outputUrl = $url;
if ($url2) {
$outputUrl .= " / {$url2}";
}
$time = round((microtime(true) - $s) * 1000);
if ($result) {
call_user_func($options['outputFn'], "{$outputUrl} ({$time}ms) {$outputMessage} ");
} else {
call_user_func($options['outputFn'], "error: {$outputType} {$outputUrl} {$outputMessage}\n\n");
}
}
}
if (isset($options['returnBody']) && $options['returnBody']) {
return $body;
} else {
return $result;
}
}
示例11: _getConfigSectionsWithTestDomain
protected static function _getConfigSectionsWithTestDomain()
{
$webConfigFull = new Zend_Config_Ini('config.ini', null);
$sections = array();
$processedDomains = array();
foreach ($webConfigFull as $k => $i) {
if ($k == 'dependencies') {
continue;
}
$config = Kwf_Config_Web::getInstance($k);
if ($config->server && $config->server->domain) {
if (!in_array($config->server->domain, $processedDomains)) {
$sections[] = $k;
$processedDomains[] = $config->server->domain;
}
}
}
$sections = array_reverse($sections);
$currentSection = Kwf_Setup::getConfigSection();
$ret = array();
foreach ($sections as $i) {
if ($i == $currentSection) {
array_unshift($ret, $i);
} else {
$ret[] = $i;
}
}
return $ret;
}
示例12: generateCode
//.........这里部分代码省略.........
$preloadClasses[] = 'Kwf_Registry';
$preloadClasses[] = 'Kwf_Trl';
$preloadClasses[] = 'Kwf_Util_SessionHandler';
$preloadClasses[] = 'Zend_Session';
$preloadClasses[] = 'Kwf_Benchmark_Counter';
$preloadClasses[] = 'Kwf_Benchmark_Counter_Apc';
if (Kwf_Component_Data_Root::getComponentClass()) {
//only load component related classes if it is a component web
$preloadClasses[] = 'Kwf_Component_Data';
$preloadClasses[] = 'Kwf_Component_Data_Root';
$preloadClasses[] = 'Kwf_Component_Settings';
$preloadClasses[] = 'Kwf_Component_Renderer_Abstract';
$preloadClasses[] = 'Kwf_Component_Renderer';
$preloadClasses[] = 'Kwf_Component_Cache';
$preloadClasses[] = 'Kwf_Component_Cache_Mysql';
$preloadClasses[] = 'Kwf_Component_Cache_Memory';
$preloadClasses[] = 'Kwf_Component_Abstract_ContentSender_Abstract';
$preloadClasses[] = 'Kwf_Component_Abstract_ContentSender_Default';
}
$ret .= self::_generatePreloadClassesCode($preloadClasses, $preloadIncludePaths);
$ret .= " } else {\n";
$preloadClasses = array();
$preloadClasses[] = 'Kwf_Assets_Loader';
$preloadClasses[] = 'Kwf_Media_Output';
$ret .= self::_generatePreloadClassesCode($preloadClasses, $preloadIncludePaths);
$ret .= " }\n";
$ret .= "}\n";
Kwf_Cache_Simple::$backend = null;
//unset to re-calculate
$ret .= "Kwf_Cache_Simple::\$backend = '" . Kwf_Cache_Simple::getBackend() . "';\n";
$cacheUniquePrefix = Kwf_Config::getValue('cachePrefix');
//can be '' when only a single web runs in memcache instance
if ($cacheUniquePrefix === null) {
$cacheUniquePrefix = getcwd() . '-' . Kwf_Setup::getConfigSection() . '-';
}
$ret .= "Kwf_Cache_Simple::\$uniquePrefix = '" . $cacheUniquePrefix . "';\n";
if (Kwf_Config::getValue('cacheSimpleNamespace')) {
$ret .= "Kwf_Cache_Simple::\$namespace = '" . Kwf_Config::getValue('cacheSimpleNamespace') . "';\n";
}
unset($cacheUniquePrefix);
if (Kwf_Config::getValue('server.memcache.host')) {
$host = Kwf_Config::getValue('server.memcache.host');
$ret .= "Kwf_Cache_Simple::\$memcacheHost = '" . $host . "';\n";
$ret .= "Kwf_Cache_Simple::\$memcachePort = '" . Kwf_Config::getValue('server.memcache.port') . "';\n";
}
if (Kwf_Config::getValue('server.redis.host')) {
$host = Kwf_Config::getValue('server.redis.host');
$ret .= "Kwf_Cache_Simple::\$redisHost = '" . $host . "';\n";
$ret .= "Kwf_Cache_Simple::\$redisPort = '" . Kwf_Config::getValue('server.redis.port') . "';\n";
}
$ret .= "if (substr(\$requestUri, 0, 8) == '/assets/') {\n";
$ret .= " \$url = \$requestUri;\n";
$ret .= " if (strpos(\$url, '?') !== false) {\n";
$ret .= " \$url = substr(\$url, 0, strpos(\$url, '?'));\n";
$ret .= " }\n";
$dispatcherClass = Kwf_Config::getValue('assets.dispatcherClass');
if (!$dispatcherClass) {
$dispatcherClass = 'Kwf_Assets_Dispatcher';
}
$ret .= " \$dispatcher = new " . $dispatcherClass . "();\n";
$ret .= " \$dispatcher->dispatch(\$url);\n";
$ret .= " Kwf_Assets_Loader::load(\$url);\n";
$ret .= "}\n";
if (Kwf_Config::getValue('debug.benchmarkCounter')) {
//vor registerAutoload aufrufen damit wir dort benchmarken können
$ret .= "Kwf_Benchmark::enableLog();\n";