public function testUnsubscribe() { // Add two subscribers $identifier = \samson\core\Event::subscribe('test.unsubscribe', array($this, 'eventDynamicCallback')); $param = 'test'; $result = \samson\core\Event::signal('test.unsubscribe', array(&$param)); // Perform test - only first subscriber must be executed $this->assertEquals(2, $result); \samson\core\Event::unsubscribe('test.unsubscribe', $identifier); $result = \samson\core\Event::signal('test.unsubscribe', array(&$param)); $this->assertEquals(null, $result); }
/** * Switch active environment * @param string $environment Configuration environment identifier */ public function change($environment = Scheme::BASE) { // Switch to configuration environment $this->active =& $this->schemes[$environment]; // Subscribe active configuration scheme to core module configure event Event::subscribe('core.module.configure', array($this, 'configure')); // If we have successfully changed configuration scheme if (!isset($this->active)) { // Signal error Event::fire('error', array($this, 'Cannot change configuration scheme to [' . $environment . '] - Configuration scheme does not exists')); // Set global scheme as active $this->active =& $this->schemes[Scheme::BASE]; } }
<?php /** * SamsonPHP initialization class */ //[PHPCOMPRESSOR(remove,start)] // Subscribe to core started event to load all possible module configurations \samson\core\Event::subscribe('core.configure', array(new \samsonos\config\Manager(), 'init')); //[PHPCOMPRESSOR(remove,end)]