2016-04-30 75 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);