Laravel 5 - 扩展抽象提供者

时间:2015-02-22 21:58:36

标签: php abstract-class laravel-5 service-provider extending-classes

我正在尝试扩展 Laravel \ Socialite \ Two \ AbstractProvider ,我不确定在Laravel中执行此操作的最佳/正确方法是什么。阅读文档让我相信我应该在服务提供商中这样做。

任何帮助都会很棒,这是我为服务提供商提供的代码:

SocialiteServiceProvider.php

<?php namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class SocialiteServiceProvider extends ServiceProvider  {

    public function register()
    {
        \App::bind('socialize', function()
        {
            echo 'DOESN\'T GET HERE';
            // what do i put here once I do get here
        });
    }
}

然后我有第二个文件

SocialiteAbstractProvider.php

<?php namespace App\Services;

use Laravel\Socialite\Two\AbstractProvider;

abstract class SocialiteAbstractProvider extends AbstractProvider
{
    /**
     * Get the authentication URL for the provider.
     *
     * @param  string  $state
     * @return string
     */
    protected function getAuthUrl($state);


    /**
     * Get the token URL for the provider.
     *
     * @return string
     */
    protected function getTokenUrl();

    /**
     * Get the raw user for the given access token.
     *
     * @param  string  $token
     * @return array
     */
    protected function getUserByToken($token);

    /**
     * Map the raw user array to a Socialite User instance.
     *
     * @param  array  $user
     * @return \Laravel\Socialite\User
     */
    protected function mapUserToObject(array $user);

    public function redirect()
    {
        echo '@s1';
        die;
        $this->request->getSession()->set(
            'state', $state = http_build_query(
                array(
                    'token' => sha1(time().$this->request->getSession()->get('_token')),
                    'domain' => $_SERVER['HTTP_HOST']
                )
            )
        );

        return new RedirectResponse($this->getAuthUrl($state));
    }
}

我也正确地将它添加到我的配置中,因为我能够看到注册事件。

0 个答案:

没有答案