| @@ -1,14 +1,14 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | defined( 'ABSPATH' ) || exit; |
| 3 | 3 | |
| 4 | -use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler; | |
| 5 | -use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; | |
| 6 | 4 | use WPIDE\App\Services\Storage\LocalFileSystem; |
| 5 | +use WPIDE\App\Classes\Freemius; | |
| 7 | 6 | |
| 8 | 7 | use const WPIDE\Constants\DIR; |
| 9 | 8 | use const WPIDE\Constants\SLUG; |
| 10 | 9 | use const WPIDE\Constants\TMP_DIR; |
| 10 | +use const WPIDE\Constants\WP_PATH; | |
| 11 | 11 | |
| 12 | 12 | return [ |
| 13 | 13 | 'WPIDE\App\Services\Logger\LoggerInterface' => [ |
| 14 | 14 | 'handler' => '\WPIDE\App\Services\Logger\Adapters\MonoLogger', |
| @@ -14,10 +14,22 @@ | ||
| 14 | 14 | 'handler' => '\WPIDE\App\Services\Logger\Adapters\MonoLogger', |
| 15 | 15 | 'config' => [ |
| 16 | 16 | 'monolog_handlers' => [ |
| 17 | 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 | + | |
| 18 | 30 | return new \Monolog\Handler\StreamHandler( |
| 19 | - ini_get('error_log'), | |
| 31 | + $logPath, | |
| 20 | 32 | \Monolog\Logger::DEBUG |
| 21 | 33 | ); |
| 22 | 34 | }, |
| 23 | 35 | ], |
| @@ -22,24 +34,8 @@ | ||
| 22 | 34 | }, |
| 23 | 35 | ], |
| 24 | 36 | ], |
| 25 | 37 | ], |
| 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 | 38 | 'WPIDE\App\Services\Cors\Cors' => [ |
| 43 | 39 | 'handler' => '\WPIDE\App\Services\Cors\Cors', |
| 44 | 40 | 'config' => [ |
| 45 | 41 | 'enabled' => defined('WP_DEBUG') && WP_DEBUG, |
| @@ -65,49 +61,18 @@ | ||
| 65 | 61 | 'config' => [], |
| 66 | 62 | ], |
| 67 | 63 | 'WPIDE\App\Services\Storage\Filesystem' => [ |
| 68 | 64 | 'handler' => '\WPIDE\App\Services\Storage\Filesystem', |
| 69 | - 'config' => LocalFileSystem::getConfig( | |
| 70 | - null, | |
| 71 | - [ | |
| 72 | - 'dirs' => LocalFileSystem::excludedDirs(), | |
| 73 | - 'files' => LocalFileSystem::excludedFiles() | |
| 74 | - ] | |
| 75 | - ), | |
| 65 | + 'config' => LocalFileSystem::getConfig(), | |
| 76 | 66 | ], |
| 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 | 67 | 'WPIDE\App\Services\Database\Database' => [ |
| 97 | - 'handler' => '\WPIDE\App\Services\Database\Database', | |
| 68 | + 'handler' => Freemius::sdk()->can_use_premium_code__premium_only() ? '\WPIDE\App\Services\Database\Database' : null, | |
| 98 | 69 | 'config' => [], |
| 99 | 70 | ], |
| 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 | - | |
| 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 | + ], | |
| 110 | 75 | 'WPIDE\App\Services\Cache\Cache' => [ |
| 111 | 76 | 'handler' => '\WPIDE\App\Services\Cache\Cache', |
| 112 | 77 | 'config' => [ |
| 113 | 78 | 'group' => SLUG |
| @@ -125,9 +90,9 @@ | ||
| 125 | 90 | ], |
| 126 | 91 | 'WPIDE\App\Services\Auth\AuthInterface' => [ |
| 127 | 92 | 'handler' => '\WPIDE\App\Services\Auth\Adapters\WPAuth', |
| 128 | 93 | 'config' => [ |
| 129 | - 'wp_dir' => ABSPATH, | |
| 94 | + 'wp_dir' => WP_PATH, | |
| 130 | 95 | 'permissions' => ['read', 'write', 'upload', 'download', 'batchdownload', 'zip'], |
| 131 | 96 | 'private_repos' => false, |
| 132 | 97 | ], |
| 133 | 98 | ], |