public static function register() { Event::listen('autoloader.realpath', function (&$path) { $path = str_replace('//', '/', $path); $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); $path = \system\Core\Module\StreamWrapper::intercept($path, 'realpath'); }); StreamWrapper::wrap(); }
public function handle($data) { // default method that will be called // do some stuff print "default handle( ) method called<br><br>"; } public function myMethod($data) { // do some stuff print "custom method has been called<br><br>"; } } /* REGISTERING THE CLASS WITH THE METHOD HANDLE( ) */ PtcEvent::listen('form.success', 'TableModel'); /* REGISTERING THE CLASS WITH A CUSTOM METHOD */ PtcEvent::listen('form.error', 'TableModel@myMethod'); /* FIRING THE EVENTS */ PtcEvent::fire('form.submit', array('form data')); PtcEvent::fire('form.error', array('form data')); /* FIRING EVENT WITH THE DATA REFERENCED */ $data = 'form data'; print "The data value: " . $data . '<br>'; PtcEvent::fire('ptc.query', array(&$data)); // adding "&" references to manipulate the data print 'Data changed thanks to the "&" reference: ' . $data . '<br><br>'; /* GETTING THE CURRENT EVENT LISTENERS */ print "<b>The current event listeners:</b><pre>"; print print_r(PtcEvent::getEvents(), true) . "</pre>"; /* REMOVING LISTENERS */ PtcEvent::remove('form.error'); // removing the last added event