Constructor
Learn how to initialize an array content provider.
The constructor initializes the provider with a versioned, localized content map that mirrors the slots.json file the CLI generates.
For each lookup, the provider serves the latest version and resolves the requested language, falling back to the default locale.
Signature
The constructor has the following signature:
public function __construct(array $slots, ?string $defaultLocale = null)Example
Here is a basic example of how to initialize an array content provider:
<?phpuse Croct\Plug\Content\ArrayContentProvider;
$provider = new ArrayContentProvider( slots: [ 'home-banner' => [ [ 'version' => 1, 'content' => [ 'en' => ['title' => 'Welcome to Croct!'], ], ], ], ], defaultLocale: 'en',);Parameters
The following list describes the supported parameters:
- slotsarray<string,array>
- defaultLocale(optional)string|null
The locale served when no language is requested or the requested one is unavailable. The default is null, which serves nothing in those cases.
Default:null