doula2426 2014-01-31 21:33
浏览 41
已采纳

Laravel 4和Sentry 2扩展了哨兵班

Having some issues trying to extend the sentry class in Sentry 2. Here is what I have done and what I am trying to do:

Created a new facade:

namespace pusers;

use Illuminate\Support\Facades\Facade;

class ADSentryFacade extends Facade {

    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return 'pusers\adsentry';
    }

}

Extedned the sentry class(all the use namespaces are there just removed to clean it up in the post). There will obviously be a lot more to this just trying to get it working at this point:

namespace pusers;

class ADSentry extends \Cartalyst\Sentry\Sentry {   
    public function authenticate(array $credentials, $remember = false, $adUser = false)
    {       
        return (string)$this->throttleProvider->isEnabled();
    }
}

Inside of app.php I changed the alias from:

'Sentry' => 'Cartalyst\Sentry\Facades\Laravel\Sentry'

to

'Sentry' => 'pusers\ADSentryFacade'

The Problem: When I use my alias its almost like nothing except the actual Sentry class is starting up. So as you can see I am trying to see if throttling is enabled or not. Using my alias(always return true) it doesnt use the config.php file but if I change it back to use the normal alias it works just fine(returning false as I have it set to false in the config).

Any hints on what I am doing wrong? I couldn't find anyone trying to extend the actual Sentry class. The only thing I found was on the sentry 2 forums one of the admins recommended someone to create a new facade and then extend Sentry but that's it.

Any other information I can provide just let me know whats needed. Thanks!

  • 写回答

1条回答 默认 最新

  • donglu9134 2014-02-01 18:25
    关注

    Well figured it out, got just enough pointers in the cartalyst channel!

    I went ahead and created a service provider. Changed the app name from sentry to adsentry. Then in my facade I changed it from 'pusers\adsentry' to just 'adsentry' and that did the trick!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算