*/ private static array $entity_bridge_cache = array(); /** * Returns true when the Entity Bridge (Hook Bus) owns writes for $meta_key on * the 'post' entity type — Zone Sync_Bridge must not also write to a Zone table. * * Replaces the former TMDO_Sync_Bridge::is_owned_by_entity_bridge(). * * @param string $meta_key Meta key being written. * @return bool */ public static function entity_bridge_owns( string $meta_key ): bool { if ( isset( self::$entity_bridge_cache[ $meta_key ] ) ) { return self::$entity_bridge_cache[ $meta_key ]; } $result = false; if ( class_exists( 'TMDO_Mode_Manager' ) && class_exists( 'TMDO_Entity_Registry' ) && TMDO_Mode_Manager::writes_to_flat( 'post' ) && null !== TMDO_Entity_Registry::get_field( 'post', $meta_key ) ) { $result = true; } self::$entity_bridge_cache[ $meta_key ] = $result; return $result; } /** * Returns true when Zone dual-write is active for the given post_type + zone. * * Replaces the repeated inline pattern: * $module = TMDO_Zone_Router::module_name( $zone, $post_type ); * TMDO_Feature_Flags::is_write_active( $module ); * * @param string $post_type Post type slug. * @param string $zone Zone identifier: 'hot', 'cold', 'warm', 'archive'. * @return bool */ public static function should_write_to_zone( string $post_type, string $zone ): bool { return TMDO_Feature_Flags::is_write_active( TMDO_Zone_Router::module_name( $zone, $post_type ) ); } /** * Returns true when Zone read-from-custom is active for the given post_type + zone. * * @param string $post_type Post type slug. * @param string $zone Zone identifier. * @return bool */ public static function should_read_from_zone( string $post_type, string $zone ): bool { return TMDO_Feature_Flags::is_read_custom( TMDO_Zone_Router::module_name( $zone, $post_type ) ); } /** * Returns true when Zone query-rewrite is active for the given post_type + zone. * * @param string $post_type Post type slug. * @param string $zone Zone identifier. * @return bool */ public static function should_query_from_zone( string $post_type, string $zone ): bool { return TMDO_Feature_Flags::is_query_active( TMDO_Zone_Router::module_name( $zone, $post_type ) ); } /** * Flush the request-level entity bridge cache. * Call this in test setUp to isolate test cases. */ public static function flush_cache(): void { self::$entity_bridge_cache = array(); } }