I was in search of some notification tool cross over the site.
For ex. I want to have something like exeptions machanism over the site but
linear and without excessive syntax. Some logics makes some actions and throws
some errors or notifications to some storage. At some steps of logics we can
check errors in this storage but the main usage of it will be at the end on
output.
This mechanism more interesting for AJAX responces when we send an answers to
client and we can send only some array of errors (maybe translated) or info
messages.
The best way I saw is using DooLog without saving logs to hdd. ^_^
For ex. I'm trying to authorize user by using AJAX and have no such account.
I'm temprary save an error by DooLog, skip some logics by checking an array of
errors (without cumbersome try...catch - for me it's not exeption, fault,
'great tragedy' but it's an event that only need to be informed to user) and
send this array of errors or info-messages to user.
I need a filtering to getLog(), something like this:
public function getLogs($levels=NULL,$categories=NULL){
if(empty($levels) && empty($categories)){
return $this->_logs;
} else {
return array_filter($this->_logs, function ($l) use ($levels,$categories) {
if (!empty($levels) && !empty($categories)) { return $l[1] == $levels && $l[2] == $categories; }
elseif (!empty($levels)) { return $l[1] == $levels; }
elseif (!empty($categories)) { return $l[2] == $categories; }
});
}
}
public function getErrs() {
return $this->getLogs(3);
}
public function getInfos() {
return $this->getLogs(6);
}
Maybe I'm crazy javascripted-man but events is a strong mechanism and I miss
for it in php ^_^
As always: PHP 5.3.6, DooPHP trunk rev. 674
Original issue reported on code.google.com by zayc...@zaycker.ru on 15 Aug 2011 at 6:06
Original issue reported on code.google.com by
zayc...@zaycker.ru
on 15 Aug 2011 at 6:06