本文整理汇总了PHP中ezcBaseInit::setCallback方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcBaseInit::setCallback方法的具体用法?PHP ezcBaseInit::setCallback怎么用?PHP ezcBaseInit::setCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcBaseInit
的用法示例。
在下文中一共展示了ezcBaseInit::setCallback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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());
}
}
示例2: 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);
}
示例3: getInstance
<?php
require_once 'tutorial_autoload.php';
// Create a custom class implementing the singleton pattern
class customSingleton
{
protected static $instance;
public static function getInstance()
{
if (self::$instance === null) {
self::$instance = new customSingleton();
ezcBaseInit::fetchConfig('customKey', self::$instance);
}
return self::$instance;
}
}
// Implement your configuration class
class customSingletonConfiguration implements ezcBaseConfigurationInitializer
{
public static function configureObject(customSingleton $object)
{
echo "Configure customSingleton.\n";
$object->value = 42;
}
}
// Register for lazy initilization
ezcBaseInit::setCallback('customKey', 'customSingletonConfiguration');
// Configure on first initilization
$object = customSingleton::getInstance();
var_dump($object->value);
示例4: dirname
<?php
$root = dirname(__FILE__);
ini_set('include_path', "/usr/share/php/ezc:{$root}");
require 'Base/ezc_bootstrap.php';
$options = new ezcBaseAutoloadOptions(array('debug' => true));
ezcBase::setOptions($options);
// Add the class repository containing our application's classes. We store
// those in the /lib directory and the classes have the "tcl" prefix.
ezcBase::addClassRepository($p = "{$root}/lib", null, 'tcl');
class customLazyCacheConfiguration implements ezcBaseConfigurationInitializer
{
public static function configureObject($id)
{
$options = array('ttl' => 1800);
switch ($id) {
case 'scrapers':
ezcCacheManager::createCache('scrapers', '../cache/scrapers', 'ezcCacheStorageFilePlain', $options);
break;
}
}
}
ezcBaseInit::setCallback('ezcInitCacheManager', 'customLazyCacheConfiguration');
示例5: configureObject
<?php
require_once 'tutorial_autoload.php';
class customLazyUrlConfiguration implements ezcBaseConfigurationInitializer
{
public static function configureObject($urlCfg)
{
// set the basedir and script values
$urlCfg->basedir = 'mydir';
$urlCfg->script = 'index.php';
// define delimiters for unordered parameter names
$urlCfg->unorderedDelimiters = array('(', ')');
// define ordered parameters
$urlCfg->addOrderedParameter('section');
$urlCfg->addOrderedParameter('group');
$urlCfg->addOrderedParameter('category');
$urlCfg->addOrderedParameter('subcategory');
// define unordered parameters
$urlCfg->addUnorderedParameter('game');
}
}
ezcBaseInit::setCallback('ezcUrlConfiguration', 'customLazyUrlConfiguration');
// Classes loaded and configured on first request
$url = new ezcUrl('http://www.example.com/mydir/index.php/groups/Games/Adventure/Adult/(game)/Larry/7', ezcUrlConfiguration::getInstance());
示例6: setUp
public function setUp($appPaths, $factory = null)
{
if (!is_null($factory)) {
if (!is_object($factory) || !method_exists($factory, 'createAppConfiguration')) {
trigger_error("\$factory argument, if specified, should be an object with method 'createAppConfiguration()'");
}
} else {
$factory = new aiiAppConfigurationFactory();
}
foreach ($appPaths as $appPath) {
// either try something else than the default app configuration
// factory, either let the user subclass this
$app = $factory->createAppConfiguration($appPath);
$this->apps[$app->namespace] = $app;
}
ezcBaseInit::setCallback('ezcInitPersistentSessionInstance', 'aiiProjectPersistentObjectInitializer');
ezcBaseInit::setCallback('ezcInitTemplateConfiguration', 'aiiProjectTemplateInitializer');
}
示例7: configureObject
<?php
require_once 'tutorial_autoload.php';
class customLazySignalConfiguration implements ezcBaseConfigurationInitializer
{
public static function configureObject($signal)
{
$signal->connect('default', 'signal', 'customFunction');
}
}
ezcBaseInit::setCallback('ezcInitSignalStaticConnections', 'customLazySignalConfiguration');
function customFunction()
{
echo "Custom function called with:\n", var_export(func_get_args(), true);
}
$signals = new ezcSignalCollection();
$signals->emit('signal', 42);
示例8: testDelayedInit
public function testDelayedInit()
{
ezcBaseInit::setCallback('ezcInitConfigurationManager', 'testDelayedInitConfigurationManager');
$cfg = ezcConfigurationManager::getInstance();
$this->assertAttributeEquals('ezcConfigurationIniReader', 'readerClass', $cfg);
}
示例9: testDelayedInit1
public function testDelayedInit1()
{
ezcBaseInit::setCallback('ezcInitPersistentSessionInstance', 'testDelayedInitPersistentSessionInstance');
$instance1 = ezcPersistentSessionInstance::get('delayed1');
}
示例10: configureObject
<?php
require_once 'tutorial_autoload.php';
class customLazyTemplateConfiguration implements ezcBaseConfigurationInitializer
{
public static function configureObject($cfg)
{
$cfg->templatePath = "/usr/share/templates";
$cfg->compilePath = "/tmp/compiled_templates";
$cfg->context = new ezcTemplateXhtmlContext();
}
}
ezcBaseInit::setCallback('ezcInitTemplateConfiguration', 'customLazyTemplateConfiguration');
$t = new ezcTemplate();
$t->process("hello_world.ezt");
示例11: 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);
}
示例12: 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');
示例13: configureObject
<?php
require_once 'tutorial_autoload.php';
class customLazyDatabaseConfiguration implements ezcBaseConfigurationInitializer
{
public static function configureObject($instance)
{
switch ($instance) {
case false:
// Default instance
return ezcDbFactory::create('mysql://user:password@host/database');
case 'sqlite':
return ezcDbFactory::create('sqlite://:memory:');
}
}
}
ezcBaseInit::setCallback('ezcInitDatabaseInstance', 'customLazyDatabaseConfiguration');
// Create and configure default mysql connection
$db = ezcDbInstance::get();
// Create and configure additional sqlite connection
$sb = ezcDbInstance::get('sqlite');
示例14: testDelayedInitialization
public function testDelayedInitialization()
{
ezcBaseInit::setCallback('ezcInitSignalStaticConnections', 'testDelayedInitSignalStaticConnections');
ezcSignalStaticConnections::getInstance()->connect('TheDelayed', 'signal', 'two');
$this->assertEquals(array(1000 => array('two', 'one')), ezcSignalStaticConnections::getInstance()->getConnections('TheDelayed', 'signal'));
}
示例15: testDelayedInit
public function testDelayedInit()
{
ezcBaseInit::setCallback('ezcInitDebug', 'testDelayedInitDebug');
$dbg = ezcDebug::getInstance();
$this->assertAttributeEquals(new TestReporter(), 'formatter', $dbg);
}