2011-06-17 48 views
0

我想製作自定義密碼散列算法。我嘗試這樣做。sfGuard自定義算法_callable

在app.cfg:

sf_guard_plugin: 
    algorithm_callable: [Hlp, noHash] 

在應用/前端/ lib中/ Hlp.php:

class Hlp 
{ 
    function noHash($password) //tried to make public or public static, but it didn't work either 
    { 
    return $password; 
    } 
} 

在我的數據庫 '算法' 設置爲 'noHash'。 當我嘗試登錄我獲得以下錯誤:

The algorithm callable "noHash" is not callable.

我使用PHP 5.2。

我在做什麼錯?

UPDATE 變化app.yml:algorithm_callable: 'HLP :: noHash'

改變了DB algorith爲 'HLP :: noHash'

標誌hakre的答案是正確的提供有用的提示。

+0

您的班級文件是否正在加載?如果不是,則該函數不可調用。檢查錯誤日誌。 – hakre 2011-06-17 08:04:32

+0

hakre,我在這堂課還有其他功能,並且在我網頁的其他部分工作得很好。我沒有在日誌中看到有關Hlp類的任何提及。 – biggusebun 2011-06-17 08:12:39

回答

1

sfGuardPlugin 1.3預計該函數在您希望調用類成員時是靜態的。

不過你的情況的錯誤消息明確指出你調用一個全球性的公共職能,否則錯誤信息會一直

The algorithm callable "Hlp::noHash" is not callable.

所以檢查設置。檢查PHP要求。如果有疑問,read the source

0

您應該正確定義您的功能。是時候離開PHP 4時代了。此外,你需要PHP> 5.2.4

... 
public static function noHash($password) 
... 

而你的意思是app.yml是嗎?