Automattic\WooCommerce\Caching

ObjectCache::get_id_from_object_if_null()privateWC 1.0

Get the id from an object if the id itself is null.

Метод класса: ObjectCache{}

Хуков нет.

Возвращает

int|Строку|null. Passed $id if it wasn't null, otherwise id obtained from $object using get_object_id.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_id_from_object_if_null( $object, $id );
$object(объект|массив) (обязательный)
The object to get the id from.
$id(int|строка|null) (обязательный)
An object id or null.

Код ObjectCache::get_id_from_object_if_null() WC 8.7.0

private function get_id_from_object_if_null( $object, $id ) {
	if ( null === $id ) {
		$id = $this->get_object_id( $object );
		if ( null === $id ) {
			throw new CacheException( "Null id supplied and the cache class doesn't implement get_object_id", $this );
		}
	}

	return $id;
}