-
Notifications
You must be signed in to change notification settings - Fork 11.5k
[9.x] Move maintenance mode logic #40070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
taylorotwell
merged 27 commits into
laravel:master
from
certegroep:#36474-enable_overwriting_maintenance_methods
Dec 17, 2021
Merged
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
e230133
chore (maintenance): move maintenance mode logic
09031d4
refactor (maintenance): add isUp method
29aaa45
doc (maintenance): document code
113f193
fix (maintenance): correctly check if in maintenance
c99e067
refactor (maintenance): use make method
27d5c68
doc (maintenance): update docblock
48aa9ff
doc (maintenance): update docblock
f66ba1c
style (doc): update documentation style
1ee6193
style (doc): update documentation style
6ec23f6
refactor (maintenance): change namespace
10ff03a
style (doc): update documentation style
10d2020
style (doc): update documentation style
1835d14
Update src/Illuminate/Foundation/Http/Middleware/PreventRequestsDurin…
wimulkeman b15b8d1
Update src/Illuminate/Foundation/Http/Middleware/PreventRequestsDurin…
wimulkeman 7f3d335
refactor (maintenance): move to application
59e4e7e
doc (maintenance): add DockBlock
1e9633f
refactor (maintenance): use application method
614c6a0
Update src/Illuminate/Foundation/MaintenanceMode.php
wimulkeman 45c9236
Update src/Illuminate/Foundation/MaintenanceMode.php
wimulkeman 2121afb
refactor (maintenance): remove comparison
2ec1619
chore (code): remove unused import
040d691
refactor (maintenance): add interface
b17e090
style (doc): update documentation style
8dd9f7a
refactor (maintenance): bind instance to contract
838f09c
style (doc): update documentation style
c617f62
Update src/Illuminate/Foundation/Providers/FoundationServiceProvider.php
wimulkeman 54ce40c
formatting and renaming
taylorotwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace Illuminate\Foundation; | ||
|
||
use function storage_path; | ||
|
||
class MaintenanceMode | ||
{ | ||
/** | ||
* Determine if the application is currently down for maintenance. | ||
* | ||
* @return bool | ||
*/ | ||
public function isDown(): bool | ||
{ | ||
return file_exists($this->getDownFilePath()); | ||
} | ||
|
||
/** | ||
* Determine if the application is currently up. | ||
* | ||
* @return bool | ||
*/ | ||
public function isUp(): bool | ||
{ | ||
return $this->isDown() === false; | ||
} | ||
|
||
/** | ||
* Take the application down for maintenance. | ||
* | ||
* @param array $payload | ||
* @return void | ||
*/ | ||
public function down(array $payload): void | ||
{ | ||
file_put_contents( | ||
$this->getDownFilePath(), | ||
json_encode($payload, JSON_PRETTY_PRINT) | ||
); | ||
} | ||
|
||
/** | ||
* Take the application out of maintenance. | ||
* | ||
* @return void | ||
*/ | ||
public function up(): void | ||
{ | ||
if ($this->isDown()) { | ||
unlink($this->getDownFilePath()); | ||
} | ||
} | ||
|
||
/** | ||
* Get the payload which was provided while the application was placed into maintenance. | ||
* | ||
* @return array | ||
*/ | ||
public function getPayload(): array | ||
{ | ||
return json_decode(file_get_contents($this->getDownFilePath()), true); | ||
} | ||
|
||
/** | ||
* Get the path where the file is stored that signals that the application is down for maintenance. | ||
* | ||
* @return string | ||
*/ | ||
protected function getDownFilePath(): string | ||
{ | ||
return storage_path('framework/down'); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.