本文整理汇总了PHP中Services::serviceAvailable方法的典型用法代码示例。如果您正苦于以下问题:PHP Services::serviceAvailable方法的具体用法?PHP Services::serviceAvailable怎么用?PHP Services::serviceAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Services
的用法示例。
在下文中一共展示了Services::serviceAvailable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: level
/**
* Sets the DebugHandler service's output level to $level. If not specified will
* return the current output level.
* @param optional integer $level
* @static
* @access public
* @return integer The current debug output level.
**/
static function level($level = null)
{
if (!Services::serviceAvailable("Debug")) {
throwError(new Error("Debug::level({$level}) called but Debug service isn't available.", "debug wrapper", false));
return;
}
$debugHandler = Services::getService("Debug");
if (is_int($level)) {
$debugHandler->setOutputLevel($level);
}
return $debugHandler->getOutputLevel();
}
示例2: ConfigSystem
/**
* The constructor.
* @param string $program The name of the program to setup configuration for, such as "Segue" or "Concerto".
**/
function ConfigSystem($program)
{
// here we need to get/create a Schema for this setup
if (!Services::serviceAvailable("SchemaManager")) {
throwError(new Error("ConfigSystem - could not continue because the SchemaManager service is not available!", "ConfigSystem", true));
return;
}
$typeManager = Services::getService("SchemaManager");
$this->_schemaType = new HarmoniType("config_system", "edu.middlebury.harmoni", $program);
$schema = new Schema($this->_schemaType);
$this->_schema = $schema;
$this->_setup = true;
$this->_record = null;
$this->_defaults = array();
}
示例3: test_start_stop_restart
function test_start_stop_restart()
{
$this->test_register_service();
//$this->assertFalse(Services::serviceRunning("DBHandler"));
// start it!
$this->assertTrue(Services::startService("DBHandler"));
$this->assertTrue(Services::serviceRunning("DBHandler"));
$this->assertTrue(Services::serviceAvailable("DBHandler"));
// stop it!
$this->assertTrue(Services::stopService("DBHandler"));
$this->assertFalse(Services::serviceRunning("DBHandler"));
$this->assertTrue(Services::serviceAvailable("DBHandler"));
// restart it! (or, first start it, *then* restart it!)
$this->assertTrue(Services::startService("DBHandler"));
$this->assertTrue(Services::serviceRunning("DBHandler"));
$this->assertTrue(Services::serviceAvailable("DBHandler"));
$this->assertTrue(Services::restartService("DBHandler"));
$this->assertTrue(Services::serviceRunning("DBHandler"));
$this->assertTrue(Services::serviceAvailable("DBHandler"));
}
示例4: define
*
*
* @package harmoni.utilities.tests
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: testList.php,v 1.4 2007/09/04 20:25:56 adamfranco Exp $
**/
if (!defined('HARMONI')) {
require_once "../../harmoni.inc.php";
}
if (!defined('SIMPLE_TEST')) {
define('SIMPLE_TEST', HARMONI . 'simple_test/');
}
require_once HARMONI . "errorHandler/ErrorHandler.class.php";
if (!Services::serviceAvailable("ErrorHandler")) {
Services::registerService("ErrorHandler", "ErrorHandler");
require_once OKI2 . "osid/OsidContext.php";
$context = new OsidContext();
$context->assignContext('harmoni', $harmoni);
require_once HARMONI . "oki2/shared/ConfigurationProperties.class.php";
$configuration = new ConfigurationProperties();
Services::startManagerAsService("ErrorHandler", $context, $configuration);
}
require_once SIMPLE_TEST . 'simple_unit.php';
require_once SIMPLE_TEST . 'dobo_simple_html_test.php';
$test = new GroupTest('Utilities tests');
$test->addTestFile(HARMONI . 'utilities/tests/OrderedListTestCase.class.php');
$test->attachObserver(new DoboTestHtmlDisplay());
$test->run();
示例5: requireService
/**
* The Require Service function checks for required service availability.
*
* The function first checks for service availabilty, and then attempts to
* start the service if it's available. If either action fails, it stops
* script execution. If $start=false then the function will only check for
* availability.
* @param string $name The name of the service.
* @param boolean $start If we should attempt to start the service or not.
* @access public
* @static
* @return ref object The started service object. (if start=true)
* @deprecated 2004/07/28 Use {@link startManagerAsService()} and {@link getService()} instead.
**/
static function requireService($service, $start = true)
{
$backtrace = debug_backtrace();
print "\n<br/><strong>Warning: Method call, Services::requireService(), is deprecated. Please use Services::startManagerAsService() and/or Services::getService() instead. ";
print $backtrace[0]['file'] . " (Line " . $backtrace[0]['line'] . ")";
print "</strong><br/>\n";
$error = false;
if (!Services::serviceAvailable($service)) {
$error = true;
} else {
if ($start && !Services::serviceRunning($service) && !Services::startService($service)) {
$error = true;
}
}
if ($error) {
// if we have the error Handler, throw a pretty error with that,
// otherwise, use the die() function.
if ($GLOBALS[SERVICES_OBJECT]->available('ErrorHandler')) {
throwError(new Error("A required Service <b>\"{$service}\"</b> " . ($start ? "could not be started" : "is not available"), "Services", 1));
} else {
$debug = debug_backtrace();
$str = "<B>FATAL ERROR</b><br /><br />";
$str .= "A required Service <b>\"{$service}\"</b> ";
$str .= $start ? "could not be started" : "is not available";
$str .= ".<br /><br />\n";
$str .= "<b>Debug backtrace:</b>\n";
$str .= "<pre>\n";
$str .= print_r($debug, true);
$str .= "\n</pre>\n";
die($str);
}
}
if ($start) {
return Services::getService($service);
}
}