Constructor
Learn how to initialize slot metadata directly.
The constructor initializes the slot metadata.
You normally read it from the fetch response instead, but you can construct it directly to provide fixed metadata in tests.
Signature
The constructor has the following signature:
public function __construct( string $version, ContentSource $contentSource, ?ExperienceMetadata $experience = null, ?array $schema = null,)Example
Here is a basic example of how to initialize slot metadata:
<?phpuse Croct\Plug\Content\ContentSource;use Croct\Plug\Content\SlotMetadata;
$metadata = new SlotMetadata( version: '1', contentSource: ContentSource::EXPERIMENT,);Parameters
The following list describes the supported parameters:
- versionstring
The content version.
- contentSource
The source the content was served from.
- experience(optional)ExperienceMetadata|null
The experience that served the content. The default is null, which means no experience applies.
Default:null- schema(optional)array<string,mixed>|null
The content schema. The default is null, which means no schema is included.
Default:null