Extending¶
Creating a custom DemandProvider¶
DemandProvider classes add new sources for demands. I.e. places where
filterrestrictions are defined. The extension already includes providers that
provide demands from the HTTP request (RequestDemandProvider) and
TypoScript (TypoScriptDemandProvider).
All DemandProvider classes must implement
Pixelant\Demander\DemandProvider\DemandProviderInterface.
This example fetches demand from an environment variable:
use Pixelant\Demander\DemandProvider\DemandProviderInterface;
class EnvironmentVariableDemandProvider implements DemandProviderInterface
{
public function getDemand(): array
{
return json_decode(getenv('APP_DEMANDER'), true);
}
}
The getDemand() method always returns an associative array of demands.
The format is explained in the
Configuration chapter’s demand section
.