Automattic\WooCommerce\Api\Attributes
Metadata::transform_description
Transform the GraphQL description of the element this attribute is applied to.
The base implementation is a no-op; the general #[Metadata] mechanism does not modify descriptions. Subclasses opt into the description-mirror convention by overriding this method — typically to prefix the input with a marker ([Internal], [Experimental], …) and supply a default body when the element has no #[Description] of its own.
Conventions for overrides:
- An empty
$descriptionmeans the element has no#[Description].If the subclass wants the marker to still reach stock introspection, it should supply a sensible default text and prefix it as usual.
- A non-empty
$descriptionmay be either the developer's own text orthe output of a previous attribute's transform; the subclass should not try to distinguish. Wrap-only (prefix the input, don't replace).
- A non-empty
When more than one transforming attribute is applied to the same element, ApiBuilder calls transform_description() once per attribute in PHP reflection (source) order, threading each return value into the next call. Because each subclass prefixes the input, the last attribute in source ends up as the outermost prefix in the final string. Order the attributes accordingly when the reading order matters.
Method of the class: Metadata{}
No Hooks.
Returns
null. Nothing (null).
Usage
$Metadata = new Metadata(); $Metadata->transform_description( $description ): string;
- $description(string) (required)
- The current description text (
''when the element has no#[Description], or the previous transform's output when chained).
Metadata::transform_description() Metadata::transform description code WC 10.9.1
public function transform_description( string $description ): string {
return $description;
}