1 |
cb15593b
|
Cajova-Houba
|
<?php
|
2 |
|
|
|
3 |
|
|
namespace Illuminate\Cache;
|
4 |
|
|
|
5 |
|
|
use Illuminate\Support\ServiceProvider;
|
6 |
|
|
use Illuminate\Cache\Console\ClearCommand;
|
7 |
|
|
|
8 |
|
|
class CacheServiceProvider extends ServiceProvider
|
9 |
|
|
{
|
10 |
|
|
/**
|
11 |
|
|
* Indicates if loading of the provider is deferred.
|
12 |
|
|
*
|
13 |
|
|
* @var bool
|
14 |
|
|
*/
|
15 |
|
|
protected $defer = true;
|
16 |
|
|
|
17 |
|
|
/**
|
18 |
|
|
* Register the service provider.
|
19 |
|
|
*
|
20 |
|
|
* @return void
|
21 |
|
|
*/
|
22 |
|
|
public function register()
|
23 |
|
|
{
|
24 |
|
|
$this->app->singleton('cache', function ($app) {
|
25 |
|
|
return new CacheManager($app);
|
26 |
|
|
});
|
27 |
|
|
|
28 |
|
|
$this->app->singleton('cache.store', function ($app) {
|
29 |
|
|
return $app['cache']->driver();
|
30 |
|
|
});
|
31 |
|
|
|
32 |
|
|
$this->app->singleton('memcached.connector', function () {
|
33 |
|
|
return new MemcachedConnector;
|
34 |
|
|
});
|
35 |
|
|
|
36 |
|
|
$this->registerCommands();
|
37 |
|
|
}
|
38 |
|
|
|
39 |
|
|
/**
|
40 |
|
|
* Register the cache related console commands.
|
41 |
|
|
*
|
42 |
|
|
* @return void
|
43 |
|
|
*/
|
44 |
|
|
public function registerCommands()
|
45 |
|
|
{
|
46 |
|
|
$this->app->singleton('command.cache.clear', function ($app) {
|
47 |
|
|
return new ClearCommand($app['cache']);
|
48 |
|
|
});
|
49 |
|
|
|
50 |
|
|
$this->commands('command.cache.clear');
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
/**
|
54 |
|
|
* Get the services provided by the provider.
|
55 |
|
|
*
|
56 |
|
|
* @return array
|
57 |
|
|
*/
|
58 |
|
|
public function provides()
|
59 |
|
|
{
|
60 |
|
|
return [
|
61 |
|
|
'cache', 'cache.store', 'memcached.connector', 'command.cache.clear',
|
62 |
|
|
];
|
63 |
|
|
}
|
64 |
|
|
}
|