protected static function setDevicesInStorage($devices)
    {
        try {
            $data = [];
            $file = (static::$deviceFile !== null) ? static::$deviceFile : WS::config()->get('device_storage');
            $content = @file_get_contents($file);
            if (!empty($content)) {
                $data = json_decode($content, true);
            }
            if(!isset($data['state'])){
                $data = ['state' => [], 'device' => []];
            }
            $data['device'] = $devices;
            $json = json_encode($data, JSON_UNESCAPED_SLASHES);
            @file_put_contents($file, $json);

            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
protected static function setDevicesInStorage($devices)
    {
        try {
            $data = [];
            $file = (static::$deviceFile !== null) ? static::$deviceFile : WS::config()->get('device_storage');
            $content = @file_get_contents($file);
            if (!empty($content)) {
                $data = json_decode($content, true);
            }
            if(!isset($data['state'])){
                $data = ['state' => [], 'device' => []];
            }
            $data['device'] = $devices;
            $json = json_encode($data, JSON_UNESCAPED_SLASHES);
            @file_put_contents($file, $json);

            return true;
        } catch (\Exception $e) {
            return false;
        }
    }
protected static function setDevicesInStorage ( $ devices ) { try { $ data = [ ] ; $ file = ( static :: $ deviceFile !== null ) ? static :: $ deviceFile : WS :: config ( ) -> get ( 'device_storage' ) ; $ content = @ file_get_contents ( $ file ) ; if ( ! empty ( $ content ) ) { $ data = json_decode ( $ content , true ) ; } if ( ! isset ( $ data [ 'state' ] ) ) { $ data = [ 'state' => [ ] , 'device' => [ ] ] ; } $ data [ 'device' ] = $ devices ; $ json = json_encode ( $ data , JSON_UNESCAPED_SLASHES ) ; @ file_put_contents ( $ file , $ json ) ; return true ; } catch ( \ Exception $ e ) { return false ; } }
Caches devices in file.

@param $devices array

@return bool
Caches devices in file .