setOption('closure', function($finisherContext) { * $formRuntime = $finisherContext->getFormRuntime(); * // ... * }); * $formDefinition->addFinisher($closureFinisher); * // ... * * Scope: frontend */ class ClosureFinisher extends AbstractFinisher { /** * @var array */ protected $defaultOptions = [ 'closure' => null, ]; /** * Executes this finisher * @see AbstractFinisher::execute() * * @throws FinisherException */ protected function executeInternal() { $closure = $this->parseOption('closure'); if ($closure === null) { return; } if (!$closure instanceof \Closure) { throw new FinisherException(sprintf('The option "closure" must be of type Closure, "%s" given.', gettype($closure)), 1332155239); } $closure($this->finisherContext); } }