コード例 #1
0
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new testBaseInitClass();
         ezcBaseInit::fetchConfig('testBaseInit', self::$instance);
     }
     return self::$instance;
 }
コード例 #2
0
 /**
  * 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
0
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new customSingleton();
         ezcBaseInit::fetchConfig('customKey', self::$instance);
     }
     return self::$instance;
 }
コード例 #4
0
ファイル: log_delayed_init_test.php プロジェクト: bmdevel/ezc
 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
0
 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
0
ファイル: instance.php プロジェクト: jou/ymc-components
 /**
  * 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];
 }
 public function testDelayedInit()
 {
     ezcBaseInit::setCallback('ezcInitConfigurationManager', 'testDelayedInitConfigurationManager');
     $cfg = ezcConfigurationManager::getInstance();
     $this->assertAttributeEquals('ezcConfigurationIniReader', 'readerClass', $cfg);
 }
コード例 #8
0
ファイル: manager.php プロジェクト: jacomyma/GEXF-Atlas
 /**
  * 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
0
 public function testDelayedInit1()
 {
     ezcBaseInit::setCallback('ezcInitDatabaseInstance', 'testDelayedInitDatabaseInstance');
     $instance1 = ezcDbInstance::get('delayed1');
 }
コード例 #10
0
 /**
  * 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
0
 public function testDelayedInit()
 {
     ezcBaseInit::setCallback('ezcInitDebug', 'testDelayedInitDebug');
     $dbg = ezcDebug::getInstance();
     $this->assertAttributeEquals(new TestReporter(), 'formatter', $dbg);
 }
コード例 #12
0
 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
0
ファイル: lhlog.php プロジェクト: Adeelgill/livehelperchat
<?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
0
 /**
  * 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
0
ファイル: configuration.php プロジェクト: jacomyma/GEXF-Atlas
 /**
  * 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];
 }
コード例 #16
0
ファイル: manager_test.php プロジェクト: zetacomponents/cache
 public function testGetCacheDelayedInit2()
 {
     testDelayedInitCacheManager::$tmpDir = $this->createTempDir(__CLASS__);
     ezcBaseInit::setCallback('ezcInitCacheManager', 'testDelayedInitCacheManager');
     $cache = ezcCacheManager::getCache('simple');
     self::assertSame('.cache', $cache->options->extension);
 }
コード例 #17
0
ファイル: configuration.php プロジェクト: bmdevel/ezc
 /**
  * Returns the value of the property $name.
  *
  * @throws ezcBasePropertyNotFoundException if the property does not exist.
  * @param string $name
  * @ignore
  */
 public function __get($name)
 {
     switch ($name) {
         case 'locale':
             return $this->properties[$name];
         case 'manager':
             if ($this->properties[$name] === null) {
                 ezcBaseInit::fetchConfig('ezcInitTemplateTranslationManager', $this);
             }
             if ($this->properties[$name] === null) {
                 throw new ezcTemplateTranslationManagerNotConfiguredException();
             }
             return $this->properties[$name];
     }
     throw new ezcBasePropertyNotFoundException($name);
 }
コード例 #18
0
ファイル: config.php プロジェクト: rangulicon/mkvmanager
<?php
/**
 * Tests configurationfile
 */
define( 'ROOT', getcwd() );
ini_set( 'include_path', "/usr/share/php/ezc:/usr/share/php" . 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( ROOT . "/lib", ROOT . "/lib/autoload", 'mm' );

class mmLazySettingsConfiguration implements ezcBaseConfigurationInitializer
{
    public static function configureObject( $cfgManager )
    {
        $cfgManager->init( 'ezcConfigurationIniReader', ROOT . "/tests/config" );
    }
}

ezcBaseInit::setCallback(
    'ezcInitConfigurationManager',
    'mmLazySettingsConfiguration'
);

?>
コード例 #19
0
<?php

require_once 'tutorial_autoload.php';
class customLazyPersistentSessionConfiguration implements ezcBaseConfigurationInitializer
{
    public static function configureObject($instance)
    {
        switch ($instance) {
            case null:
                // Default instance
                $session = new ezcPersistentSession(ezcDbInstance::get(), new ezcPersistentCodeManager('../persistent'));
                return $session;
            case 'second':
                $session = new ezcPersistentSession(ezcDbInstance::get(), new ezcPersistentCodeManager('../additionalPersistent'));
                return $session;
        }
    }
}
ezcBaseInit::setCallback('ezcInitPersistentSessionInstance', 'customLazyPersistentSessionConfiguration');
// Create and configure default persistent session
$db = ezcPersistentSessionInstance::get();
// Create and configure additional persistent session
$sb = ezcPersistentSessionInstance::get('second');
コード例 #20
0
<?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");
コード例 #21
0
            // @TODO: Add a proper exception type here.
            throw new Exception( "Unknown / unmapped DB type '$dbType'" );
        }

        $dbType = $dbMapping[$dbType];

        $dsnHost = $dbHost . ( $dbPort != '' ? ":$dbPort" : '' );
        $dsnAuth = $dbUser . ( $dbPass != '' ? ":$dbPass" : '' );
        $dsn = "{$dbType}://{$dbUser}:{$dbPass}@{$dsnHost}/{$dbName}";

        return $dsn;
    }
}
ezcBaseInit::setCallback( 'ezcInitDatabaseInstance', 'ezpRestDbConfig' );

class ezpRestPoConfig implements ezcBaseConfigurationInitializer
{
    public static function configureObject( $instance )
    {
        return new ezcPersistentSession( ezcDbInstance::get(),
            new ezcPersistentMultiManager( array(
                new ezcPersistentCodeManager( 'kernel/private/rest/classes/po_maps/' ),
                new ezcPersistentCodeManager( 'kernel/private/oauth/classes/persistentobjects/' )
            ))
        );
    }
}
ezcBaseInit::setCallback( 'ezcInitPersistentSessionInstance', 'ezpRestPoConfig' );

?>
コード例 #22
0
<?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://*****:*****@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');
コード例 #23
0
<?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());
コード例 #24
0
 public function testDelayedInit1()
 {
     ezcBaseInit::setCallback('ezcInitPersistentSessionInstance', 'testDelayedInitPersistentSessionInstance');
     $instance1 = ezcPersistentSessionInstance::get('delayed1');
 }
コード例 #25
0
<?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);
コード例 #26
0
ファイル: config.php プロジェクト: bdunogier/tcl
<?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');
コード例 #27
0
ファイル: debug.php プロジェクト: Adeelgill/livehelperchat
 /**
  * Returns the instance of this class.
  *
  * When the ezcDebug instance is created it is automatically added to the instance
  * of ezcLog.
  *
  * @return ezcDebug
  */
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new ezcDebug();
         ezcBaseInit::fetchConfig('ezcInitDebug', self::$instance);
     }
     return self::$instance;
 }
コード例 #28
0
 /**
  * Returns the instance of the class
  *
  * @param boolean $isCliMode
  * @return CjwNewsletterLog
  */
 public static function getInstance($isCliMode = false)
 {
     try {
         if (is_null(self::$instance)) {
             self::$instance = new self($isCliMode);
             ezcBaseInit::fetchConfig('cjwNewsletterInitLog', self::$instance);
         }
         return self::$instance;
     } catch (ezcBaseFilePermissionException $e) {
         eZDebug::writeError($e->getMessage(), 'CjwNewsletterLog::getInstance()');
         if ($isCliMode) {
             $output = new ezcConsoleOutput();
             $output->formats->error->color = 'red';
             $output->formats->error->style = array('bold');
             $output->outputLine($e->getMessage(), 'error');
             exit;
         }
     }
 }
コード例 #29
0
ファイル: cron.php プロジェクト: p4prawin/livechat
function __autoload($className)
{
    ezcBase::autoload($className);
}
ezcBase::addClassRepository(dirname(__FILE__) . '/', dirname(__FILE__) . '/lib/autoloads');
$input = new ezcConsoleInput();
$helpOption = $input->registerOption(new ezcConsoleOption('s', 'siteaccess', ezcConsoleInput::TYPE_STRING));
$cronjobPartOption = $input->registerOption(new ezcConsoleOption('c', 'cronjob', ezcConsoleInput::TYPE_STRING));
$cronjobPathOption = $input->registerOption(new ezcConsoleOption('p', 'path', ezcConsoleInput::TYPE_STRING));
$extensionPartOption = $input->registerOption(new ezcConsoleOption('e', 'extension', ezcConsoleInput::TYPE_STRING));
try {
    $input->process();
} catch (ezcConsoleOptionException $e) {
    die($e->getMessage());
}
ezcBaseInit::setCallback('ezcInitDatabaseInstance', 'erLhcoreClassLazyDatabaseConfiguration');
$instance = erLhcoreClassSystem::instance();
$instance->SiteAccess = $helpOption->value;
$instance->SiteDir = dirname(__FILE__) . '/';
$cfgSite = erConfigClassLhConfig::getInstance();
$defaultSiteAccess = $cfgSite->getSetting('site', 'default_site_access');
$optionsSiteAccess = $cfgSite->getSetting('site_access_options', $helpOption->value);
$instance->Language = $optionsSiteAccess['locale'];
$instance->ThemeSite = $optionsSiteAccess['theme'];
$instance->WWWDirLang = '/' . $helpOption->value;
// php cron.php -s site_admin -c cron/workflow
// php cron.php -s site_admin -e customstatus -c cron/customcron
if ($extensionPartOption->value) {
    include_once 'extension/' . $extensionPartOption->value . '/modules/lh' . $cronjobPartOption->value . '.php';
} else {
    include_once 'modules/lh' . $cronjobPartOption->value . '.php';
コード例 #30
0
 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'));
 }