valid($this->getEntity()->isLoaded() ? $this->getEntity() : null); } public function initialize(FormContextInterface $context) : void { if(isset($this->contextClass) && ! $context instanceof $this->contextClass ) { throw new \LogicException( sprintf("Your context type should be a %s, received %s", $this->contextClass, $context::class) ); } } public function lang(string $key, array $variables = []) { return $this->languageHandler->languageFromKey($key, $variables); } public function getEntity() : EntityInterface|EntityCollection { if (! isset($this->entity)) { throw new \InvalidArgumentException($this->lang("lean.api.form.error.entity")); } return $this->entity; } }