当前位置: 首页>>代码示例>>PHP>>正文


PHP ezcBaseInit::setCallback方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:BGCX261,项目名称:zphp-svn-to-git,代码行数:9,代码来源:base_init_test.php

示例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);
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:9,代码来源:log_delayed_init_test.php

示例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);
开发者ID:mediasadc,项目名称:alba,代码行数:30,代码来源:tutorial_lazy_initialization.php

示例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');
开发者ID:bdunogier,项目名称:tcl,代码行数:23,代码来源:config.php

示例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());
开发者ID:bmdevel,项目名称:ezc,代码行数:24,代码来源:tutorial_lazy_initialization.php

示例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');
 }
开发者ID:jpic,项目名称:ezc-framework-apps,代码行数:18,代码来源:framework_part0.php

示例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);
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:17,代码来源:tutorial_lazy_initialization.php

示例8: testDelayedInit

 public function testDelayedInit()
 {
     ezcBaseInit::setCallback('ezcInitConfigurationManager', 'testDelayedInitConfigurationManager');
     $cfg = ezcConfigurationManager::getInstance();
     $this->assertAttributeEquals('ezcConfigurationIniReader', 'readerClass', $cfg);
 }
开发者ID:zetacomponents,项目名称:configuration,代码行数:6,代码来源:configuration_manager_delayed_init_test.php

示例9: testDelayedInit1

 public function testDelayedInit1()
 {
     ezcBaseInit::setCallback('ezcInitPersistentSessionInstance', 'testDelayedInitPersistentSessionInstance');
     $instance1 = ezcPersistentSessionInstance::get('delayed1');
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:5,代码来源:instance_delayed_init_test.php

示例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");
开发者ID:bmdevel,项目名称:ezc,代码行数:15,代码来源:tutorial_lazy_initialization.php

示例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);
 }
开发者ID:zetacomponents,项目名称:url,代码行数:7,代码来源:url_configuration_test.php

示例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');
开发者ID:Adeelgill,项目名称:livehelperchat,代码行数:23,代码来源:lhlog.php

示例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');
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:21,代码来源:tutorial_lazy_initialization.php

示例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'));
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:6,代码来源:static_connections_test.php

示例15: testDelayedInit

 public function testDelayedInit()
 {
     ezcBaseInit::setCallback('ezcInitDebug', 'testDelayedInitDebug');
     $dbg = ezcDebug::getInstance();
     $this->assertAttributeEquals(new TestReporter(), 'formatter', $dbg);
 }
开发者ID:bmdevel,项目名称:ezc,代码行数:6,代码来源:debug_delayed_init_test.php


注:本文中的ezcBaseInit::setCallback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。