PluginProbe
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings / 7.2.1
MLSImport: IDX Plugin & MLS Plugin for Real Estate Listings v7.2.1
7.2.2 7.2.1 7.2 7.1.2 7.1.1 7.1 7.0.4 7.0.6 7.0.7 6.3.8 6.3.7 6.3.6 6.3.5 6.3.4 6.3.3 6.3.1 trunk 5.7.3 5.7.5 5.8.1 5.8.2 5.8.3 5.8.4 5.8.6 6.0.4 All 37 releases
← All changes | enviroment/BridgeResoClass.php +48 -5 7.0.4 → 7.2.1 View file →
@@ -1,13 +1,10 @@
1 1 <?php
2 2 /**
3 3 * MLS provider adapter: Bridge (Bridge Data Output API, RESO standard).
4 4 *
5 - * One of the per-provider adapters in enviroment/ that sit between an MLS data
6 - * source and the active theme importer. This class is a thin subtype of
7 - * ResoBase; it holds a reference to the theme importer so provider-specific
8 - * mapping can delegate to the theme adapter. Bridge currently adds no
9 - * behaviour of its own beyond holding that reference.
5 + * Owns Bridge identity, Stored request exceptions, native Direct MLS queries,
6 + * endpoint rewriting, and saved-token login.
10 7 */
11 8 if ( ! defined( 'ABSPATH' ) ) {
12 9 // Block direct web access — only load when WordPress is bootstrapped.
13 10 exit; // Exit if accessed directly
@@ -25,9 +22,14 @@
25 22 * @author cretu
26 23 */
27 24 class BridgeResoClass extends ResoBase {
28 25
26 + /** @var string Stable provider type saved for Bridge. */
27 + protected $provider_type = 'bridge';
29 28
29 + /** @var bool Bridge sends its saved bearer token unchanged. */
30 + protected $direct_uses_stored_token = true;
31 +
30 32 // Active theme adapter (e.g. ResidenceClass) this provider maps RESO fields through.
31 33 public $theme_importer;
32 34
33 35 /**
@@ -37,6 +39,47 @@
37 39 */
38 40 public function __construct( $theme_importer ) {
39 41 // Keep the theme adapter reference for later field mapping.
40 42 $this->theme_importer = $theme_importer;
43 + }
44 +
45 + /** Format Bridge sync times with seconds and no forced UTC suffix. */
46 + protected function format_stored_timestamp( $value ) {
47 + return $this->format_utc_timestamp( $value, false, false );
48 + }
49 +
50 + /** Remove StandardStatus for Edmonton, whose feed has no status field. */
51 + public function prepare_stored_request( array $arguments, $last_date = '' ) {
52 + if ( isset( $arguments['mls_id'] ) && 111 === (int) $arguments['mls_id'] ) {
53 + unset( $arguments['status'] );
54 + }
55 + return parent::prepare_stored_request( $arguments, $last_date );
56 + }
57 +
58 + /**
59 + * Build Bridge's native listings query instead of an OData query.
60 + *
61 + * @param array $params Standalone filter and paging values.
62 + * @param array $config Per-MLS config including field_corellation.
63 + * @return string
64 + */
65 + public function build_direct_query( array $params, array $config ) {
66 + return mlsimport_live_build_query_bridge( $params, $config );
67 + }
68 +
69 + /** Build Bridge's native exact-ListingKey query. */
70 + public function build_direct_get_query( $listing_key, array $config ) {
71 + return '?ListingKey=' . rawurlencode( (string) $listing_key );
72 + }
73 +
74 + /**
75 + * Rewrite Bridge's configured OData Property URL to its native listings URL.
76 + *
77 + * @param array $config Per-MLS configuration.
78 + * @return string
79 + */
80 + public function direct_endpoint( array $config ) {
81 + $base = parent::direct_endpoint( $config );
82 + $native = preg_replace( '#/OData/([^/?]+)/Property/?#i', '/$1/listings', $base );
83 + return is_string( $native ) && '' !== $native ? $native : $base;
41 84 }
42 85 }