Automattic\WooCommerce\Blocks\Assets
AssetDataRegistry::add_data()
See self::add() for docs.
Method of the class: AssetDataRegistry{}
No Hooks.
Return
null
. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->add_data( $key, $data );
- $key(string) (required)
- Key for the data.
- $data(mixed) (required)
- Value for the data.
AssetDataRegistry::add_data() AssetDataRegistry::add data code WC 8.7.0
protected function add_data( $key, $data ) { if ( ! is_string( $key ) ) { if ( $this->debug() ) { throw new InvalidArgumentException( 'Key for the data being registered must be a string' ); } } if ( isset( $this->data[ $key ] ) ) { if ( $this->debug() ) { throw new InvalidArgumentException( 'Overriding existing data with an already registered key is not allowed' ); } return; } if ( \is_callable( $data ) ) { $this->lazy_data[ $key ] = $data; return; } $this->data[ $key ] = $data; }