| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; |
| 5 |
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; |
| 6 |
use WPIDE\App\Services\Storage\LocalFileSystem; |
| 7 |
|
| 8 |
use const WPIDE\Constants\DIR; |
| 9 |
use const WPIDE\Constants\SLUG; |
| 10 |
use const WPIDE\Constants\TMP_DIR; |
| 11 |
|
| 12 |
return [ |
| 13 |
'WPIDE\App\Services\Logger\LoggerInterface' => [ |
| 14 |
'handler' => '\WPIDE\App\Services\Logger\Adapters\MonoLogger', |
| 15 |
'config' => [ |
| 16 |
'monolog_handlers' => [ |
| 17 |
function () { |
| 18 |
return new \Monolog\Handler\StreamHandler( |
| 19 |
ini_get('error_log'), |
| 20 |
\Monolog\Logger::DEBUG |
| 21 |
); |
| 22 |
}, |
| 23 |
], |
| 24 |
], |
| 25 |
], |
| 26 |
'WPIDE\App\Services\Session\SessionStorageInterface' => [ |
| 27 |
'handler' => '\WPIDE\App\Services\Session\Adapters\SessionStorage', |
| 28 |
'config' => [ |
| 29 |
'name' => SLUG, |
| 30 |
'handler' => function () { |
| 31 |
$save_path = null; // use default system path |
| 32 |
$handler = new NativeFileSessionHandler($save_path); |
| 33 |
|
| 34 |
return new NativeSessionStorage([ |
| 35 |
"cookie_samesite" => "Lax", |
| 36 |
"cookie_secure" => null, |
| 37 |
"cookie_httponly" => true, |
| 38 |
], $handler); |
| 39 |
}, |
| 40 |
], |
| 41 |
], |
| 42 |
'WPIDE\App\Services\Cors\Cors' => [ |
| 43 |
'handler' => '\WPIDE\App\Services\Cors\Cors', |
| 44 |
'config' => [ |
| 45 |
'enabled' => defined('WP_DEBUG') && WP_DEBUG, |
| 46 |
], |
| 47 |
], |
| 48 |
'WPIDE\App\Services\Tmpfs\TmpfsInterface' => [ |
| 49 |
'handler' => '\WPIDE\App\Services\Tmpfs\Adapters\Tmpfs', |
| 50 |
'config' => [ |
| 51 |
'path' => TMP_DIR, |
| 52 |
'gc_probability_perc' => 10, |
| 53 |
'gc_older_than' => 60 * 60 * 24 * 2, // 2 days |
| 54 |
], |
| 55 |
], |
| 56 |
'WPIDE\App\Services\Security\Security' => [ |
| 57 |
'handler' => '\WPIDE\App\Services\Security\Security', |
| 58 |
'config' => [ |
| 59 |
'ip_allowlist' => [], |
| 60 |
'ip_denylist' => [] |
| 61 |
], |
| 62 |
], |
| 63 |
'WPIDE\App\Services\View\ViewInterface' => [ |
| 64 |
'handler' => '\WPIDE\App\Services\View\Adapters\Vuejs', |
| 65 |
'config' => [], |
| 66 |
], |
| 67 |
'WPIDE\App\Services\Storage\Filesystem' => [ |
| 68 |
'handler' => '\WPIDE\App\Services\Storage\Filesystem', |
| 69 |
'config' => LocalFileSystem::getConfig( |
| 70 |
null, |
| 71 |
[ |
| 72 |
'dirs' => LocalFileSystem::excludedDirs(), |
| 73 |
'files' => LocalFileSystem::excludedFiles() |
| 74 |
] |
| 75 |
), |
| 76 |
], |
| 77 |
// 'WPIDE\App\Services\Storage\Filesystem' => [ |
| 78 |
// 'handler' => '\WPIDE\App\Services\Storage\Filesystem', |
| 79 |
// 'config' => [ |
| 80 |
// 'separator' => '/', |
| 81 |
// 'config' => [], |
| 82 |
// 'adapter' => function () { |
| 83 |
// $client = new \Aws\S3\S3Client([ |
| 84 |
// 'credentials' => [ |
| 85 |
// 'key' => AWS_ACCESS_KEY, |
| 86 |
// 'secret' => AWS_SECRET_KEY |
| 87 |
// ], |
| 88 |
// 'region' => 'us-east-1', |
| 89 |
// 'version' => 'latest', |
| 90 |
// ]); |
| 91 |
// |
| 92 |
// return new \League\Flysystem\AwsS3v3\AwsS3Adapter($client, 'bervana'); |
| 93 |
// }, |
| 94 |
// ], |
| 95 |
// ], |
| 96 |
'WPIDE\App\Services\Database\Database' => [ |
| 97 |
'handler' => '\WPIDE\App\Services\Database\Database', |
| 98 |
'config' => [], |
| 99 |
], |
| 100 |
// 'WPIDE\App\Services\Database\DatabaseApi' => [ |
| 101 |
// 'handler' => '\WPIDE\App\Services\Database\DatabaseApi', |
| 102 |
// 'config' => [ |
| 103 |
// 'username' => DB_USER, |
| 104 |
// 'password' => DB_PASSWORD, |
| 105 |
// 'database' => DB_NAME, |
| 106 |
// 'address' => DB_HOST |
| 107 |
// ] |
| 108 |
// ], |
| 109 |
|
| 110 |
'WPIDE\App\Services\Cache\Cache' => [ |
| 111 |
'handler' => '\WPIDE\App\Services\Cache\Cache', |
| 112 |
'config' => [ |
| 113 |
'group' => SLUG |
| 114 |
], |
| 115 |
], |
| 116 |
'WPIDE\App\Services\Transient\Transient' => [ |
| 117 |
'handler' => '\WPIDE\App\Services\Transient\Transient', |
| 118 |
'config' => [ |
| 119 |
'prefix' => SLUG.'_' |
| 120 |
], |
| 121 |
], |
| 122 |
'WPIDE\App\Services\Archiver\ArchiverInterface' => [ |
| 123 |
'handler' => '\WPIDE\App\Services\Archiver\Adapters\ZipArchiver', |
| 124 |
'config' => [], |
| 125 |
], |
| 126 |
'WPIDE\App\Services\Auth\AuthInterface' => [ |
| 127 |
'handler' => '\WPIDE\App\Services\Auth\Adapters\WPAuth', |
| 128 |
'config' => [ |
| 129 |
'wp_dir' => ABSPATH, |
| 130 |
'permissions' => ['read', 'write', 'upload', 'download', 'batchdownload', 'zip'], |
| 131 |
'private_repos' => false, |
| 132 |
], |
| 133 |
], |
| 134 |
'WPIDE\App\Services\Router\Router' => [ |
| 135 |
'handler' => '\WPIDE\App\Services\Router\Router', |
| 136 |
'config' => [ |
| 137 |
'query_param' => 'req', |
| 138 |
'routes_file' => DIR.'_routes.php', |
| 139 |
], |
| 140 |
], |
| 141 |
]; |
| 142 |
|