Plugins
Minimal example
Using plugins
<?php
use ForestAdmin\AgentPHP\Agent\Utils\Env;
use ForestAdmin\AgentPHP\DatasourceCustomizer\CollectionCustomizer;
use ForestAdmin\AgentPHP\DatasourceDoctrine\DoctrineDatasource;
use ForestAdmin\SymfonyForestAdmin\Service\ForestAgent;
use MyNamespace\Plugins\CreateFileField;
use MyNamespace\Plugins\RemoveTimestamps;
// The use() method can be called both on the agent and on collections
return static function (ForestAgent $forestAgent) {
$forestAgent->addDatasource(
new DoctrineDatasource($forestAgent->getEntityManager(), [
'url' => Env::get('DATABASE_URL'),
]),
)
// Some plugins do not require options
->use(RemoveTimestamps::class)
// Others do
->customizeCollection(
'Book',
fn (CollectionCustomizer $builder) => $builder->use(
CreateFileField::class,
['fieldname': 'avatar']
)
)Writing plugins
Last updated