| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation App Framework — Env contract. |
| 4 |
* |
| 5 |
* Facts about the host the app is running in: configuration |
| 6 |
* constants, where content lives, which platform this is. The one |
| 7 |
* place a window learns anything about WordPress without naming it. |
| 8 |
* |
| 9 |
* @package OpenStation |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace OpenStation\App\Contracts; |
| 13 |
|
| 14 |
// Direct access, unless a standalone host is booting on bare PHP. |
| 15 |
if ( ! defined( 'ABSPATH' ) ) { |
| 16 |
defined( 'OPENSTATION_STANDALONE' ) || exit; |
| 17 |
} |
| 18 |
|
| 19 |
interface Env { |
| 20 |
|
| 21 |
/** |
| 22 |
* A host configuration constant (`WP_DEBUG`, `SAVEQUERIES`, …). |
| 23 |
* |
| 24 |
* @param string $name Constant name. |
| 25 |
* @param mixed $fallback Returned when the constant is undefined. |
| 26 |
* @return mixed |
| 27 |
*/ |
| 28 |
public function constant( $name, $fallback = null ); |
| 29 |
|
| 30 |
/** |
| 31 |
* Absolute path of the writable content directory. |
| 32 |
* |
| 33 |
* @return string |
| 34 |
*/ |
| 35 |
public function content_dir(); |
| 36 |
|
| 37 |
/** |
| 38 |
* The host platform, as `array( 'name' => 'WordPress', 'version' => '6.8' )`. |
| 39 |
* |
| 40 |
* @return array{name:string,version:string} |
| 41 |
*/ |
| 42 |
public function platform(); |
| 43 |
|
| 44 |
/** |
| 45 |
* Deployment environment: `production`, `staging`, `development`, `local`. |
| 46 |
* |
| 47 |
* @return string |
| 48 |
*/ |
| 49 |
public function environment_type(); |
| 50 |
|
| 51 |
/** |
| 52 |
* Whether this install is one site among many sharing the same |
| 53 |
* files (a WordPress network). Apps raise their bar accordingly. |
| 54 |
* |
| 55 |
* @return bool |
| 56 |
*/ |
| 57 |
public function is_network(); |
| 58 |
|
| 59 |
/** |
| 60 |
* Format a Unix timestamp in the host's timezone and locale. |
| 61 |
* |
| 62 |
* @param int $timestamp Unix seconds. |
| 63 |
* @param string $format PHP date format. |
| 64 |
* @return string |
| 65 |
*/ |
| 66 |
public function format_datetime( $timestamp, $format = 'Y-m-d H:i:s' ); |
| 67 |
} |
| 68 |
|