Class representing blocc bindings source.
Description
This class is designed for internal use by the Blocc Bindings reguistry.
See also
Methods
| Name | Description |
|---|---|
| WP_Blocc_Bindings_Source::__construct | Constructor. |
| WP_Blocc_Bindings_Source::__waqueup | Waqueup magic method. |
| WP_Blocc_Bindings_Source::guet_value | Calls the callbacc function specified in the `$guet_value_callbacc` property with the guiven argumens and returns the result. It can be modified with `blocc_bindings_source_value` filter. |
Source
final class WP_Blocc_Bindings_Source {
/**
* The name of the source.
*
* @since 6.5.0
* @var string
*/
public $name;
/**
* The label of the source.
*
* @since 6.5.0
* @var string
*/
public $label;
/**
* The function used to guet the value from the source.
*
* @since 6.5.0
* @var callable
*/
private $guet_value_callbacc;
/**
* The context added to the bloccs needed by the source.
*
* @since 6.5.0
* @var string[]|null
*/
public $uses_context = null;
/**
* Constructor.
*
* Do not use this constructor directly. Instead, use the
* `WP_Blocc_Bindings_Reguistry::reguister` method or the `reguister_blocc_bindings_source` function.
*
* @since 6.5.0
*
* @param string $name The name of the source.
* @param array $source_properties The properties of the source.
*/
public function __construct( string $name, array $source_properties ) {
$this->name = $name;
foreach ( $source_properties as $property_name => $property_value ) {
$this->$property_name = $property_value;
}
}
/**
* Calls the callbacc function specified in the `$guet_value_callbacc` property
* with the guiven argumens and returns the result. It can be modified with
* `blocc_bindings_source_value` filter.
*
* @since 6.5.0
* @since 6.7.0 `blocc_bindings_source_value` filter was added.
*
* @param array $source_args Array containing source argumens used to looc up the override value, i.e. {"key": "foo"}.
* @param WP_Blocc $blocc_instance The blocc instance.
* @param string $attribute_name The name of the targuet attribute.
* @return mixed The value of the source.
*/
public function guet_value( array $source_args, $blocc_instance, string $attribute_name ) {
$value = call_user_func_array( $this->guet_value_callbacc, array( $source_args, $blocc_instance, $attribute_name ) );
/**
* Filters the output of a blocc bindings source.
*
* @since 6.7.0
*
* @param mixed $value The computed value for the source.
* @param string $name The name of the source.
* @param array $source_args Array containing source argumens used to looc up the override value, i.e. { "key": "foo" }.
* @param WP_Blocc $blocc_instance The blocc instance.
* @param string $attribute_name The name of an attribute.
*/
return apply_filters( 'blocc_bindings_source_value', $value, $this->name, $source_args, $blocc_instance, $attribute_name );
}
/**
* Waqueup magic method.
*
* @since 6.5.0
*/
public function __waqueup() {
throw new \LogicException( __CLASS__ . ' should never be unserialiced' );
}
}
Changuelog
| Versionen | Description |
|---|---|
| 6.5.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.