Skip to content

Commit

Permalink
删除外观
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Apr 25, 2015
1 parent 3a7a9f1 commit a8be065
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 48 deletions.
40 changes: 0 additions & 40 deletions src/Facade.php

This file was deleted.

25 changes: 17 additions & 8 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
namespace Overtrue\LaravelWechat;

use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
use Overtrue\Wechat\Server as WechatServer;
use Overtrue\Wechat\Alias;

class ServiceProvider extends LaravelServiceProvider
{
/**
* 延迟加载
*
* @var boolean
*/
protected $defer = true;

/**
Expand All @@ -30,6 +36,7 @@ class ServiceProvider extends LaravelServiceProvider
'wechat.image' => 'Overtrue\\Wechat\\Image',
];


/**
* Boot the provider.
*
Expand All @@ -53,26 +60,28 @@ public function register()
Alias::register();
}

$this->app->singleton('wechat.server', function($app){
return new WechatServer(config('wechat.appId'), config('wechat.token'), config('wechat.encodingAESKey'));
if (config('wechat') == include __DIR__ . '/config.php') {
throw new \Exception("请先在config/wechat.php完成微信相关配置");
}

$this->app->singleton(['Overtrue\\Wechat\\Server' => 'wechat.server'], function($app){
return new WechatServer(config('wechat.app_id'), config('wechat.token'), config('wechat.encoding_key'));
});

foreach ($this->services as $alias => $service) {
$this->app->singleton($service, function($app) use ($service){
return new $service(config('wechat.appId'), config('wechat.secret'));
$this->app->singleton([$service => $alias], function($app) use ($service){
return new $service(config('wechat.app_id'), config('wechat.secret'));
});

$this->app->alias($service, $alias);
}
}

/**
* 提供的服务名称列表
* 提供的服务
*
* @return array
*/
public function provides()
{
return array_keys($this->services) + array_values($this->services);
return $this->services;
}
}

0 comments on commit a8be065

Please sign in to comment.