2016-04-30 74 views
2

嗨我正在使用slim和cartalyst \ sentinel登錄應用程序。當我創建哨兵提醒$reminder = new Cartalyst\Sentinel\Reminders\IlluminateReminderRepository;的新實例時,它會給UserRepositoryInterface error __construct() must implement interface Cartalyst\Sentinel\Users\UserRepositoryInterface實施一個錯誤。在運行時實現接口PHP

我的問題是我如何在運行時在php中實現一個接口。

雖然在上面我使用了激活類,它也實現了src代碼中的接口,如class IlluminateActivationRepository implements ActivationRepositoryInterface但它不會給出錯誤。

這下面的激活類工作正常。

$activation = (new Cartalyst\Sentinel\Activations\IlluminateActivationRepository)->create($user); 

回答

1

好吧,我解決了這個提供用戶存儲庫對象。

$users = $app->container->sentinel->getUserRepository(); 

$reminder = new Cartalyst\Sentinel\Reminders\IlluminateReminderRepository ($users);