Automattic\WooCommerce\Internal\PushNotifications\DataStores
NotificationPreferencesDataStore::read
Read the stored envelope for a user.
Migrates older schema versions on the fly and persists the upgrade so callers always receive a current-version envelope. Returns null when nothing is stored for the user.
Метод класса: NotificationPreferencesDataStore{}
Хуков нет.
Возвращает
array|null. Envelope with schema_version and preferences keys, or null if unstored.
Использование
$NotificationPreferencesDataStore = new NotificationPreferencesDataStore(); $NotificationPreferencesDataStore->read( $user_id ): ?array;
- $user_id(int) (обязательный)
- The user ID.
Список изменений
| С версии 10.8.0 | Введена. |
Код NotificationPreferencesDataStore::read() NotificationPreferencesDataStore::read WC 11.2.2
public function read( int $user_id ): ?array {
$stored = Users::get_site_user_meta( $user_id, self::META_KEY );
if ( ! is_array( $stored ) || empty( $stored ) ) {
return null;
}
$stored_version = isset( $stored['schema_version'] ) ? (int) $stored['schema_version'] : 0;
if ( $stored_version < self::CURRENT_SCHEMA_VERSION ) {
$stored = $this->migrate( $stored, $stored_version );
$this->write( $user_id, $stored );
}
return $stored;
}