| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
use WPIDE\App\Services\Storage\LocalFileSystem; |
| 5 |
use WPIDE\App\Classes\Freemius; |
| 6 |
|
| 7 |
use const WPIDE\Constants\DIR; |
| 8 |
use const WPIDE\Constants\SLUG; |
| 9 |
use const WPIDE\Constants\TMP_DIR; |
| 10 |
use const WPIDE\Constants\WP_PATH; |
| 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 |
$logPath = ini_get('error_log'); |
| 19 |
|
| 20 |
if (! is_string($logPath) || $logPath === '' || is_dir($logPath)) { |
| 21 |
$logPath = defined('WP_CONTENT_DIR') |
| 22 |
? WP_CONTENT_DIR . '/debug.log' |
| 23 |
: TMP_DIR . '/wpide.log'; |
| 24 |
} |
| 25 |
|
| 26 |
if (is_dir($logPath)) { |
| 27 |
$logPath = TMP_DIR . '/wpide.log'; |
| 28 |
} |
| 29 |
|
| 30 |
return new \Monolog\Handler\StreamHandler( |
| 31 |
$logPath, |
| 32 |
\Monolog\Logger::DEBUG |
| 33 |
); |
| 34 |
}, |
| 35 |
], |
| 36 |
], |
| 37 |
], |
| 38 |
'WPIDE\App\Services\Cors\Cors' => [ |
| 39 |
'handler' => '\WPIDE\App\Services\Cors\Cors', |
| 40 |
'config' => [ |
| 41 |
'enabled' => defined('WP_DEBUG') && WP_DEBUG, |
| 42 |
], |
| 43 |
], |
| 44 |
'WPIDE\App\Services\Tmpfs\TmpfsInterface' => [ |
| 45 |
'handler' => '\WPIDE\App\Services\Tmpfs\Adapters\Tmpfs', |
| 46 |
'config' => [ |
| 47 |
'path' => TMP_DIR, |
| 48 |
'gc_probability_perc' => 10, |
| 49 |
'gc_older_than' => 60 * 60 * 24 * 2, // 2 days |
| 50 |
], |
| 51 |
], |
| 52 |
'WPIDE\App\Services\Security\Security' => [ |
| 53 |
'handler' => '\WPIDE\App\Services\Security\Security', |
| 54 |
'config' => [ |
| 55 |
'ip_allowlist' => [], |
| 56 |
'ip_denylist' => [] |
| 57 |
], |
| 58 |
], |
| 59 |
'WPIDE\App\Services\View\ViewInterface' => [ |
| 60 |
'handler' => '\WPIDE\App\Services\View\Adapters\Vuejs', |
| 61 |
'config' => [], |
| 62 |
], |
| 63 |
'WPIDE\App\Services\Storage\Filesystem' => [ |
| 64 |
'handler' => '\WPIDE\App\Services\Storage\Filesystem', |
| 65 |
'config' => LocalFileSystem::getConfig(), |
| 66 |
], |
| 67 |
'WPIDE\App\Services\Database\Database' => [ |
| 68 |
'handler' => Freemius::sdk()->can_use_premium_code__premium_only() ? '\WPIDE\App\Services\Database\Database' : null, |
| 69 |
'config' => [], |
| 70 |
], |
| 71 |
'WPIDE\App\Services\ConfigManager\ConfigManager' => [ |
| 72 |
'handler' => Freemius::sdk()->can_use_premium_code__premium_only() ? '\WPIDE\App\Services\ConfigManager\ConfigManager' : null, |
| 73 |
'config' => [], |
| 74 |
], |
| 75 |
'WPIDE\App\Services\Cache\Cache' => [ |
| 76 |
'handler' => '\WPIDE\App\Services\Cache\Cache', |
| 77 |
'config' => [ |
| 78 |
'group' => SLUG |
| 79 |
], |
| 80 |
], |
| 81 |
'WPIDE\App\Services\Transient\Transient' => [ |
| 82 |
'handler' => '\WPIDE\App\Services\Transient\Transient', |
| 83 |
'config' => [ |
| 84 |
'prefix' => SLUG.'_' |
| 85 |
], |
| 86 |
], |
| 87 |
'WPIDE\App\Services\Archiver\ArchiverInterface' => [ |
| 88 |
'handler' => '\WPIDE\App\Services\Archiver\Adapters\ZipArchiver', |
| 89 |
'config' => [], |
| 90 |
], |
| 91 |
'WPIDE\App\Services\Auth\AuthInterface' => [ |
| 92 |
'handler' => '\WPIDE\App\Services\Auth\Adapters\WPAuth', |
| 93 |
'config' => [ |
| 94 |
'wp_dir' => WP_PATH, |
| 95 |
'permissions' => ['read', 'write', 'upload', 'download', 'batchdownload', 'zip'], |
| 96 |
'private_repos' => false, |
| 97 |
], |
| 98 |
], |
| 99 |
'WPIDE\App\Services\Router\Router' => [ |
| 100 |
'handler' => '\WPIDE\App\Services\Router\Router', |
| 101 |
'config' => [ |
| 102 |
'query_param' => 'req', |
| 103 |
'routes_file' => DIR.'_routes.php', |
| 104 |
], |
| 105 |
], |
| 106 |
]; |
| 107 |
|