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\Foundation\MaintenanceMode as MaintenanceModeContract;
6
 
7
class FileBasedMaintenanceMode implements MaintenanceModeContract
8
{
9
    /**
10
     * Take the application down for maintenance.
11
     *
12
     * @param  array  $payload
13
     * @return void
14
     */
15
    public function activate(array $payload): void
16
    {
17
        file_put_contents(
18
            $this->path(),
19
            json_encode($payload, JSON_PRETTY_PRINT)
20
        );
21
    }
22
 
23
    /**
24
     * Take the application out of maintenance.
25
     *
26
     * @return void
27
     */
28
    public function deactivate(): void
29
    {
30
        if ($this->active()) {
31
            unlink($this->path());
32
        }
33
    }
34
 
35
    /**
36
     * Determine if the application is currently down for maintenance.
37
     *
38
     * @return bool
39
     */
40
    public function active(): bool
41
    {
42
        return file_exists($this->path());
43
    }
44
 
45
    /**
46
     * Get the data array which was provided when the application was placed into maintenance.
47
     *
48
     * @return array
49
     */
50
    public function data(): array
51
    {
52
        return json_decode(file_get_contents($this->path()), true);
53
    }
54
 
55
    /**
56
     * Get the path where the file is stored that signals that the application is down for maintenance.
57
     *
58
     * @return string
59
     */
60
    protected function path(): string
61
    {
62
        return storage_path('framework/down');
63
    }
64
}