|
1
|
|
|
<?php namespace Algorit\Synchronizer; |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Filesystem\Filesystem; |
|
4
|
|
|
use Illuminate\Support\ServiceProvider; |
|
5
|
|
|
|
|
6
|
|
|
use Monolog\Handler\StreamHandler; |
|
7
|
|
|
use Algorit\Synchronizer\Request\Config; |
|
8
|
|
|
|
|
9
|
|
|
use Algorit\Synchronizer\Storage\Sync; |
|
10
|
|
|
use Algorit\Synchronizer\Storage\SyncEloquentRepository; |
|
11
|
|
|
|
|
12
|
|
|
class SynchronizerServiceProvider extends ServiceProvider { |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Indicates if loading of the provider is deferred. |
|
16
|
|
|
* |
|
17
|
|
|
* @var bool |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $defer = true; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Bootstrap the application events. |
|
23
|
|
|
* |
|
24
|
|
|
* @return void |
|
25
|
|
|
*/ |
|
26
|
|
|
public function boot() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->package('algorit/synchronizer'); |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
$this->app['algorit.synchronizer'] = $this->app->share(function($app) |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
$sync = new SyncEloquentRepository(new Sync); |
|
33
|
|
|
|
|
34
|
|
|
$builder = new Builder(new Sender, new Receiver, $sync); |
|
35
|
|
|
|
|
36
|
|
|
return new Loader($app, $builder, new Config(new Filesystem)); |
|
37
|
|
|
}); |
|
38
|
|
|
|
|
39
|
|
|
require 'helpers.php'; |
|
40
|
|
|
|
|
41
|
|
|
$this->bootLogger(); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function bootLogger() |
|
45
|
|
|
{ |
|
46
|
|
|
$logger = $this->app['log']; |
|
47
|
|
|
|
|
48
|
|
|
if($logger == false) |
|
49
|
|
|
{ |
|
50
|
|
|
return false; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$handler = new StreamHandler('php://output'); |
|
54
|
|
|
|
|
55
|
|
|
$monolog = $logger->getMonolog(); |
|
56
|
|
|
$monolog->pushHandler($handler); |
|
57
|
|
|
|
|
58
|
|
|
$this->app['algorit.synchronizer']->setLogger($logger); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Register the service provider. |
|
63
|
|
|
* |
|
64
|
|
|
* @return void |
|
65
|
|
|
*/ |
|
66
|
|
|
public function register(){} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Get the services provided by the provider. |
|
70
|
|
|
* |
|
71
|
|
|
* @return array |
|
72
|
|
|
*/ |
|
73
|
|
|
public function provides() |
|
74
|
|
|
{ |
|
75
|
|
|
return array('algorit.synchronizer'); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
} |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: