我以爲我會回傳上面的代碼,但稍微修改一下才能正常工作。需要分配$ magento,以及用於grep的路徑。只要將/ var/www/app更改爲任何您的magento目錄即可。將此腳本複製到一個文件並執行它。你需要安裝ack-grep才能正常工作。 Ubuntu用戶可以輸入「sudo apt-get ack-grep」,我相信會安裝它,或者只是google ack-grep。
這是一個shell PHP SCRIPT。如果你在瀏覽器中運行它,它看起來就像一個MESS!但是,您可以執行「php whateveryoucallthescript.php >> output.txt」,然後在VI中打開該文件或對其進行編輯並搜索您想要的結果。
這對企業1.11.1.0在Magento明確解僱,內部隱含的人一起事件
<?php
$magento = "/var/www/app/";
$results = `ack-grep Mage::dispatchEvent $magento 2>/dev/null | grep -v "/var/www/app/code/local" | grep -v "/var/www/downloader/pearlib"`;
$results = explode("\n", $results);
print_error(sprintf("%-100s\t%-4s\t%s\n", "FILE", "LINE", "EVENT"));
foreach($results as $result) {
if(!strlen(trim($result))) { continue; }
$matches = array();
preg_match("/([^:]+):(\d+):\W+(.*)/", $result, $matches);
$file = str_replace($magento, "", $matches[1]);
$line = $matches[2];
$event = $matches[3];
$eventMatches = array();
if(preg_match("/Mage::dispatchEvent\('(\w+)'\);/", $event, $eventMatches)) {
$event = $eventMatches[1];
$matchType = 1;
} else if(preg_match("/Mage::dispatchEvent\('(\w+)',.*/", $event, $eventMatches)) {
$event = $eventMatches[1];
$matchType = 2;
} else if(preg_match("/Mage::dispatchEvent\($/", $event)) {
$event = get_next_line_event($file, $line+1, $magento);
$matchType = 3;
} else if(preg_match("/Mage::dispatchEvent\(\"?(['\$a-zA-Z._{}\-> ]+).*/", $event, $eventMatches)) {
$event = $eventMatches[1];
$matchType = 4;
} else {
print "Found unmatcheable event:\n";
var_dump($event);
}
printf("%-100s\t%-4s\t%s\n", $file, $line, $event);
}
function get_next_line_event($file, $line, $magento) {
$cnt = `cat -n $magento/$file | grep -e "^ *$line"`;
$cnt = preg_replace("/^\s*\d*\s*/", "", $cnt);
$matches = array();
if(preg_match("/^'?([\$a-z_>. -]*)'?,$/i", $cnt, $matches)) {
return $matches[1];
} else if(preg_match("/^([\$a-z_>. '\-\(\)]*),$/i", $cnt, $matches)) {
return $matches[1];
}
print "Found unmatcheable event:\n";
var_dump($cnt);exit;
}
function print_error($err) {
echo $err;
}
?>
我的問題是稍微主觀的,不太清楚Stack Overflow是什麼。 – clockworkgeek 2011-03-12 16:03:43