public function notify(Zym_Message $message) { if ('testEvent' == $message->getName()) { // Assume Zend_Log instance $log = Zend_Registry::get('log'); $log->log('testEvent was triggered and received by MyClass!'); } }
/** * Tests Zym_Message->reset() */ public function testReset() { $this->_dispatcher->attach($this, 'test'); $hasObserver = $this->_dispatcher->hasObserver($this, 'test'); $this->assertTrue($hasObserver); $this->_dispatcher->reset(); $hasObserver = $this->_dispatcher->hasObserver($this, 'test'); $this->assertFalse($hasObserver); }
/** * Tests Zym_Message->getSender() */ public function testGetSender() { $sender = $this->_message->getSender(); $this->assertEquals($this->_mockSender, $sender); }
/** * Setup cache after resources are setup * * @internal * @param Zym_Message $message */ public function onAfterResourceSetup(Zym_Message $message) { $sender = $message->getSender(); if ($sender instanceof Zym_App_Resource_Cache) { $config = $this->getConfig('cache'); $backend = $config->get('backend') ? $config->get('backend') : Zym_Cache::getDefaultBackend(); $backendConfig = Zym_Cache::getBackendOptions($backend); $frontendConfig = Zym_Cache::getFrontendOptions('Core'); // Save $filename = $this->getPath(self::PATH_DATA, 'cache'); $cache = Zend_Cache::factory('Core', 'File', array('automatic_serialization' => true, 'cache_id_prefix' => $this->getName(true) . '__' . $this->getEnvironment() . '__' . get_class($this) . '__'), array('cache_dir' => $filename, 'file_name_prefix' => get_class($this))); $cache->save(array($backend, $frontendConfig, $backendConfig), 'cache'); } }
/** * Enter description here... * * @param Zym_Message $message */ public function hello(Zym_Message $message) { printf('Name: %s, <br />Sender: %s, <br />Notifier: %s()', $message->getName(), get_class($message->getSender()), __METHOD__); }