本文整理汇总了PHP中ezcBaseInit类的典型用法代码示例。如果您正苦于以下问题:PHP ezcBaseInit类的具体用法?PHP ezcBaseInit怎么用?PHP ezcBaseInit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ezcBaseInit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new testBaseInitClass();
ezcBaseInit::fetchConfig('testBaseInit', self::$instance);
}
return self::$instance;
}
示例2: getInstance
/**
* Returns the instance of the ezcSignalStaticConnections..
*
* @return ezcConfigurationManager
*/
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new ezcSignalStaticConnections();
ezcBaseInit::fetchConfig('ezcInitSignalStaticConnections', self::$instance);
}
return self::$instance;
}
示例3: getInstance
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new customSingleton();
ezcBaseInit::fetchConfig('customKey', self::$instance);
}
return self::$instance;
}
示例4: testDelayedInit
public function testDelayedInit()
{
ezcBaseInit::setCallback('ezcInitLog', 'testDelayedInitLog');
$log = ezcLog::getInstance();
$rule = new ezcLogFilterRule(new ezcLogFilter(), $writer = new ezcLogUnixFileWriter('/'), true);
$expected = new ezcLogFilterSet();
$expected->appendRule($rule);
$this->assertAttributeEquals($expected, 'writers', $log);
}
示例5: testCallback3
public function testCallback3()
{
try {
ezcBaseInit::setCallback('testBaseInit', 'testBaseInitCallback');
$this->fail("Expected exception not thrown.");
} catch (ezcBaseInitCallbackConfiguredException $e) {
$this->assertEquals("The 'testBaseInit' is already configured with callback class 'testBaseInitCallback'.", $e->getMessage());
}
}
示例6: get
/**
* Returns the persistent session instance named $identifier.
*
* If $identifier is ommited the default persistent session
* specified by chooseDefault() is returned.
*
* @throws ezcPersistentSessionNotFoundException if the specified instance is not found.
* @param string $identifier
* @return ezcPersistentSession
*/
public static function get($identifier = null)
{
if ($identifier === null && self::$defaultInstanceIdentifier) {
$identifier = self::$defaultInstanceIdentifier;
}
if (!isset(self::$instances[$identifier])) {
// The ezcInitPersistentSessionInstance callback should return an
// ezcPersistentSession object which will then be set as instance.
$ret = ezcBaseInit::fetchConfig('ymcJobQueueInstance', $identifier);
if ($ret === null) {
throw new Exception('Did not find queue instance ' . $identifier);
} else {
self::set($ret, $identifier);
}
}
return self::$instances[$identifier];
}
示例7: testDelayedInit
public function testDelayedInit()
{
ezcBaseInit::setCallback('ezcInitConfigurationManager', 'testDelayedInitConfigurationManager');
$cfg = ezcConfigurationManager::getInstance();
$this->assertAttributeEquals('ezcConfigurationIniReader', 'readerClass', $cfg);
}
示例8: getCache
/**
* Returns the ezcCacheStorage object with the given ID.
* The cache ID has to be defined before using the
* {@link ezcCacheManager::createCache()} method. If no instance of this
* cache does exist yet, it's created on the fly. If one exists, it will
* be reused.
*
* @param string $id The ID of the cache to return.
* @return ezcCacheStorage The cache with the given ID.
*
* @throws ezcCacheInvalidIdException
* If the ID of a cache you try to access does not exist. To access
* a cache using this method, it first hast to be created using
* {@link ezcCacheManager::createCache()}.
* @throws ezcBaseFileNotFoundException
* If the storage location does not exist. This should usually not
* happen, since {@link ezcCacheManager::createCache()} already
* performs sanity checks for the cache location. In case this
* exception is thrown, your cache location has been corrupted
* after the cache was configured.
* @throws ezcBaseFileNotFoundException
* If the storage location is not a directory. This should usually
* not happen, since {@link ezcCacheManager::createCache()} already
* performs sanity checks for the cache location. In case this
* exception is thrown, your cache location has been corrupted
* after the cache was configured.
* @throws ezcBaseFilePermissionException
* If the storage location is not writeable. This should usually not
* happen, since {@link ezcCacheManager::createCache()} already
* performs sanity checks for the cache location. In case this
* exception is thrown, your cache location has been corrupted
* after the cache was configured.
* @throws ezcBasePropertyNotFoundException
* If you tried to set a non-existent option value. The accepted
* options depend on the ezcCacheStorage implementation and may
* vary.
*/
public static function getCache($id)
{
// Look for already existing cache object
if (!isset(self::$caches[$id])) {
// Failed, look for configuration, and if it does not exist, use
// delayed initialization.
if (!isset(self::$configurations[$id])) {
ezcBaseInit::fetchConfig('ezcInitCacheManager', $id);
}
// Check whether delayed initialization actually worked, if not,
// throw an exception
if (!isset(self::$configurations[$id])) {
throw new ezcCacheInvalidIdException($id);
}
$class = self::$configurations[$id]['class'];
self::$caches[$id] = new $class(self::$configurations[$id]['location'], self::$configurations[$id]['options']);
}
return self::$caches[$id];
}
示例9: testDelayedInit1
public function testDelayedInit1()
{
ezcBaseInit::setCallback('ezcInitDatabaseInstance', 'testDelayedInitDatabaseInstance');
$instance1 = ezcDbInstance::get('delayed1');
}
示例10: getInstance
/**
* Returns the instance of the class ezcConfigurationManager.
*
* @return ezcConfigurationManager
*/
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new ezcConfigurationManager();
ezcBaseInit::fetchConfig('ezcInitConfigurationManager', self::$instance);
}
return self::$instance;
}
示例11: testDelayedInit
public function testDelayedInit()
{
ezcBaseInit::setCallback('ezcInitDebug', 'testDelayedInitDebug');
$dbg = ezcDebug::getInstance();
$this->assertAttributeEquals(new TestReporter(), 'formatter', $dbg);
}
示例12: testDelayedInit
public function testDelayedInit()
{
ezcBaseInit::setCallback('ezcUrlConfiguration', 'testDelayedInitUrlConfiguration');
$urlCfg = ezcUrlConfiguration::getInstance();
$this->assertEquals(array('section' => 0), $urlCfg->orderedParameters);
$this->assertEquals(array('article' => 1), $urlCfg->unorderedParameters);
}
示例13: write
<?php
class erLhcoreClassLog implements ezcBaseConfigurationInitializer
{
// to write to the log put a write statement in the code with the content to log
//
// Example: erLhcoreClassLog::write(print_r($_POST,true));
// or: erLhcoreClassLog::write("Log entry");
//
// default log location is CACHE/DEFAULT.LOG since it is writable Change below.
static function write($msg)
{
// Use log
$log = ezcLog::getInstance();
$log->log($msg, ezcLog::WARNING);
}
public static function configureObject($log)
{
$writeAll = new ezcLogUnixFileWriter("cache", "default.log");
$log->getMapper()->appendRule(new ezcLogFilterRule(new ezcLogFilter(), $writeAll, true));
}
}
ezcBaseInit::setCallback('ezcInitLog', 'erLhcoreClassLog');
示例14: get
/**
* Returns the database instance $identifier.
*
* If $identifier is ommited the default database instance
* specified by chooseDefault() is returned.
*
* @throws ezcDbHandlerNotFoundException if the specified instance is not found.
* @param string $identifier
* @return ezcDbHandler
*/
public static function get($identifier = false)
{
if ($identifier === false && self::$DefaultInstanceIdentifier) {
$identifier = self::$DefaultInstanceIdentifier;
}
if (!isset(self::$Instances[$identifier])) {
// The DatabaseInstanceFetchConfig callback should return an
// ezcDbHandler object which will then be set as instance.
$ret = ezcBaseInit::fetchConfig('ezcInitDatabaseInstance', $identifier);
if ($ret === null) {
throw new ezcDbHandlerNotFoundException($identifier);
} else {
self::set($ret, $identifier);
}
}
return self::$Instances[$identifier];
}
示例15: getInstance
/**
* Returns the unique configuration instance named $name.
*
* Note: You only need to specify the name if you need multiple configuration
* objects.
*
* @param string $name Name of the configuration to use.
* @return ezcTemplateConfiguration
*/
public static function getInstance($name = "default")
{
if (!isset(self::$instanceList[$name])) {
self::$instanceList[$name] = new ezcTemplateConfiguration();
ezcBaseInit::fetchConfig('ezcInitTemplateConfiguration', self::$instanceList[$name]);
}
return self::$instanceList[$name];
}