Example #1
0
 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));
     }
 }
Example #2
0
 /**
  * @return  Registry
  */
 protected function getState()
 {
     return Registry::getInstance($this->_statekey);
 }
Example #3
0
 /**
  * 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__ . '.');
 }
 /**
  * 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__ . '.');
 }
Example #5
0
 /**
  * @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.');
 }