# getSlotContent

Learn how to provide the content of a slot.

An implementation must return the content of the given slot for the requested language, or `null` when no content is available.

## Signature

This method has the following signature:

```php
public function getSlotContent(string $id, ?string $language = null): ?array
```

This method returns the slot content as an associative array, or `null` when no content is available.

## Example

This example loads each slot's content from a CMS:

```php
<?php
use Croct\Plug\Content\ContentProvider;

final class CmsContentProvider implements ContentProvider
{
    private Cms $cms;

    public function __construct(Cms $cms)
    {
        $this->cms = $cms;
    }

    public function getSlotContent(string $id, ?string $language = null): ?array
    {
        // Fetch the slot's content from your CMS or database.
        return $this->cms->getContent($id, $language);
    }
}
```

## Parameters

The following list describes the supported parameters:

- `id`: `string`

  The ID of the slot.

- `language`: `string|null` (optional) (default: null)

  The preferred language. The default is `null`, which serves the default language.
