| 1 |
<?php |
| 2 |
|
| 3 |
namespace RexTheme\WPVR\Api\Repositories; |
| 4 |
|
| 5 |
use RexTheme\WPVR\Api\Contracts\RepositoryInterface; |
| 6 |
|
| 7 |
class TourRepository implements RepositoryInterface { |
| 8 |
|
| 9 |
const META_KEY = 'panodata'; |
| 10 |
|
| 11 |
public function find( int $id ): array { |
| 12 |
$raw = get_post_meta( $id, self::META_KEY, true ); |
| 13 |
return is_array( $raw ) ? $raw : []; |
| 14 |
} |
| 15 |
|
| 16 |
public function save( int $id, array $data ): bool { |
| 17 |
$result = update_post_meta( $id, self::META_KEY, $data ); |
| 18 |
// update_post_meta returns false both on real failure and when value is unchanged |
| 19 |
if ( false === $result ) { |
| 20 |
return get_post_meta( $id, self::META_KEY, true ) == $data; |
| 21 |
} |
| 22 |
return true; |
| 23 |
} |
| 24 |
} |
| 25 |
|