本文整理汇总了PHP中Joomla\Registry\Registry::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::getInstance方法的具体用法?PHP Registry::getInstance怎么用?PHP Registry::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joomla\Registry\Registry
的用法示例。
在下文中一共展示了Registry::getInstance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(&$subject, $config = array())
{
parent::__construct($subject, $config);
// Prepare log object
$registry = Registry::getInstance("com_crowdfunding");
/** @var $registry Registry */
$fileName = $registry->get("logger.file");
$tableName = $registry->get("logger.table");
// Create log object
$this->log = new Prism\Log\Log();
// Set database writer.
$this->log->addWriter(new Prism\Log\Writer\Database(\JFactory::getDbo(), $tableName));
// Set file writer.
if (!empty($fileName)) {
$app = \JFactory::getApplication();
/** @var $app \JApplicationSite */
$file = \JPath::clean($app->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
$this->log->addWriter(new Prism\Log\Writer\File($file));
}
}
示例2: getState
/**
* @return Registry
*/
protected function getState()
{
return Registry::getInstance($this->_statekey);
}
示例3: testGetInstance
/**
* Test the Joomla\Registry\Registry::getInstance method.
*
* @return void
*
* @covers Joomla\Registry\Registry::getInstance
* @since 1.0
*/
public function testGetInstance()
{
// Test INI format.
$a = Registry::getInstance('a');
$b = Registry::getInstance('a');
$c = Registry::getInstance('c');
// Check the object type.
$this->assertInstanceOf('\\Joomla\\Registry\\Registry', $a, 'Line ' . __LINE__ . ' - Object $a should be an instance of Registry.');
// Check cache handling for same registry id.
$this->assertThat($a, $this->identicalTo($b), 'Line: ' . __LINE__ . '.');
// Check cache handling for different registry id.
$this->assertThat($a, $this->logicalNot($this->identicalTo($c)), 'Line: ' . __LINE__ . '.');
}
示例4: testGetInstance
/**
* Test the Joomla\Registry\Registry::getInstance method.
*
* @return void
*
* @covers Joomla\Registry\Registry::getInstance
* @since 1.0
*/
public function testGetInstance()
{
// Test INI format.
$a = Registry::getInstance('a');
$b = Registry::getInstance('a');
$c = Registry::getInstance('c');
// Check the object type.
$this->assertThat($a instanceof Joomla\Registry\Registry, $this->isTrue(), 'Line: ' . __LINE__ . '.');
// Check cache handling for same registry id.
$this->assertThat($a, $this->identicalTo($b), 'Line: ' . __LINE__ . '.');
// Check cache handling for different registry id.
$this->assertThat($a, $this->logicalNot($this->identicalTo($c)), 'Line: ' . __LINE__ . '.');
}
示例5: testACachedRegistryInstanceIsReturned
/**
* @testdox A cached Registry instance is returned
*
* @covers Joomla\Registry\Registry::getInstance
*/
public function testACachedRegistryInstanceIsReturned()
{
$a = Registry::getInstance('a');
$b = Registry::getInstance('a');
$c = Registry::getInstance('c');
$this->assertInstanceOf('Joomla\\Registry\\Registry', $a, 'A Registry instance should be returned.');
$this->assertSame($a, $b, 'The same Registry instance should be returned when requesting the same ID.');
$this->assertNotSame($a, $c, 'Different Registry instances should be returned when requesting different ID\'s.');
}