| 1 |
<?php |
| 2 |
/** |
| 3 |
* Unsupported Provider Family result. |
| 4 |
* |
| 5 |
* The public Provider Family module returns this object when a saved provider |
| 6 |
* type is unknown. Returning a normal result object lets every caller show the |
| 7 |
* same safe error without catching exceptions or silently using Bridge rules. |
| 8 |
* |
| 9 |
* @package MLSImport |
| 10 |
*/ |
| 11 |
|
| 12 |
if ( ! defined( 'ABSPATH' ) ) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Read-only adapter-shaped result for an unsupported saved provider type. |
| 18 |
*/ |
| 19 |
class UnsupportedResoClass extends ResoBase { |
| 20 |
/** @var bool Unknown providers cannot execute Direct MLS requests. */ |
| 21 |
protected $direct_access_supported = false; |
| 22 |
|
| 23 |
/** @var string The unrecognized saved provider type. */ |
| 24 |
private $unsupported_type; |
| 25 |
|
| 26 |
/** |
| 27 |
* Store the invalid type so the error identifies the broken configuration. |
| 28 |
* |
| 29 |
* @param string $unsupported_type Unrecognized provider type from saved config. |
| 30 |
*/ |
| 31 |
public function __construct( $unsupported_type ) { |
| 32 |
$this->unsupported_type = (string) $unsupported_type; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Return the exact unrecognized type for logs and diagnostics. |
| 37 |
* |
| 38 |
* @return string |
| 39 |
*/ |
| 40 |
public function type() { |
| 41 |
return $this->unsupported_type; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* Report that requests cannot be made with this adapter. |
| 46 |
* |
| 47 |
* @return bool |
| 48 |
*/ |
| 49 |
public function supported() { |
| 50 |
return false; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Return a stable safe error for admin screens and request callers. |
| 55 |
* |
| 56 |
* @return array{code:string,message:string} |
| 57 |
*/ |
| 58 |
public function error() { |
| 59 |
return array( |
| 60 |
'code' => 'unsupported_provider', |
| 61 |
'message' => 'This MLS provider type is not supported.', |
| 62 |
); |
| 63 |
} |
| 64 |
} |
| 65 |
|