Пример #1
0
 public static function find($name)
 {
     $file = ExiguousEcommerceConfig::getDataDirectory() . self::$directory . '/' . basename($name) . '.json';
     if (!file_exists($file)) {
         throw new \Exception('File does not exist: ' . $file);
     }
     if (!($data = json_decode(file_get_contents($file)))) {
         throw new \Exception('Error exists in file (' . json_last_error_msg() . '): ' . $file);
     }
     return new self($name, $data);
 }
 public static function save($directory, $object)
 {
     $file = ExiguousEcommerceConfig::getDataDirectory() . $directory . '/' . $object->id . '.json';
     $data = json_encode($object->data, JSON_PRETTY_PRINT);
     file_put_contents($file, $data);
 }