Automattic\WooCommerce\Caching
ObjectCache::get_id_from_object_if_null
Get the id from an object if the id itself is null.
Method of the class: ObjectCache{}
No Hooks.
Returns
Int|String|null. Passed $id if it wasn't null, otherwise id obtained from $object using get_object_id.
Usage
// private - for code of main (parent) class only $result = $this->get_id_from_object_if_null( $object, $id );
- $object(object|array) (required)
- The object to get the id from.
- $id(int|string|null) (required)
- An object id or null.
ObjectCache::get_id_from_object_if_null() ObjectCache::get id from object if null code WC 10.3.6
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;
}