Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Foundation;
4
 
5
use Illuminate\Contracts\Cache\Factory;
6
use Illuminate\Contracts\Cache\Repository;
7
use Illuminate\Contracts\Foundation\MaintenanceMode;
8
 
9
class CacheBasedMaintenanceMode implements MaintenanceMode
10
{
11
    /**
12
     * The cache factory.
13
     *
14
     * @var \Illuminate\Contracts\Cache\Factory
15
     */
16
    protected $cache;
17
 
18
    /**
19
     * The cache store that should be utilized.
20
     *
21
     * @var string
22
     */
23
    protected $store;
24
 
25
    /**
26
     * The cache key to use when storing maintenance mode information.
27
     *
28
     * @var string
29
     */
30
    protected $key;
31
 
32
    /**
33
     * Create a new cache based maintenance mode implementation.
34
     *
35
     * @param  \Illuminate\Contracts\Cache\Factory  $cache
36
     * @param  string  $store
37
     * @param  string  $key
38
     * @return void
39
     */
40
    public function __construct(Factory $cache, string $store, string $key)
41
    {
42
        $this->cache = $cache;
43
        $this->store = $store;
44
        $this->key = $key;
45
    }
46
 
47
    /**
48
     * Take the application down for maintenance.
49
     *
50
     * @param  array  $payload
51
     * @return void
52
     */
53
    public function activate(array $payload): void
54
    {
55
        $this->getStore()->put($this->key, $payload);
56
    }
57
 
58
    /**
59
     * Take the application out of maintenance.
60
     *
61
     * @return void
62
     */
63
    public function deactivate(): void
64
    {
65
        $this->getStore()->forget($this->key);
66
    }
67
 
68
    /**
69
     * Determine if the application is currently down for maintenance.
70
     *
71
     * @return bool
72
     */
73
    public function active(): bool
74
    {
75
        return $this->getStore()->has($this->key);
76
    }
77
 
78
    /**
79
     * Get the data array which was provided when the application was placed into maintenance.
80
     *
81
     * @return array
82
     */
83
    public function data(): array
84
    {
85
        return $this->getStore()->get($this->key);
86
    }
87
 
88
    /**
89
     * Get the cache store to use.
90
     *
91
     * @return \Illuminate\Contracts\Cache\Repository
92
     */
93
    protected function getStore(): Repository
94
    {
95
        return $this->cache->store($this->store);
96
    }
97
}