Skip to content

How to generate such a code? #84

Answered by dg
svfolder asked this question in Q&A
Discussion options

You must be logged in to vote

https://fiddle.nette.org/nette/#6c8292c389

$closure = new Nette\PhpGenerator\Closure;
$closure->setBody('return $model->getBrand()->one()->name;');
$closure->addParameter('model')->setType(BrandAliasAssignment::class);

echo (new Nette\PhpGenerator\Dumper)->dump([
    'attribute' => 'brand_id',
    'filter' => new Nette\PhpGenerator\PhpLiteral('$searchModel->brandList()'),
    'value' => new Nette\PhpGenerator\PhpLiteral((string) $closure),
]);

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by svfolder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants