123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- /**
- * Created by PhpStorm.
- * User: robin
- * Date: 10/3/16
- * Time: 6:05 PM
- */
-
- namespace App\DataAccess;
-
-
- use Luticate\Utils\Controller\LuticateApplication;
-
- class UsersSettingsDataAccess
- {
- public static function getDir()
- {
- $dir = LuticateApplication::getInstance()->getSetting("USERS_SETTING_DIR");
- return __DIR__ . "/../../${dir}/";
- }
-
- public static function getFilePath(string $id)
- {
- $dir = static::getDir();
- $filename = preg_replace("([^a-zA-Z0-9])", '_', $id);
- return $dir . $filename;
- }
-
- public static function put(string $settings, string $id)
- {
- $filePath = self::getFilePath($id);
- file_put_contents($filePath, $settings);
- return true;
- }
-
- public static function get(string $id)
- {
- $filePath = self::getFilePath($id);
- if (file_exists($filePath)) {
- $settings = file_get_contents($filePath);
- return $settings;
- }
- return null;
- }
- }
|