/** * @param WebChemistry\Forms\Form $form * @param object $values */ public function successForm(WebChemistry\Forms\Form $form, $values) { if ($form->getSubmittedName() === 'preview') { $explode = explode('___', $form->getName()); $class = str_replace('_', '\\', $explode[0]); $method = $explode[1]; $class = $this->provider->getByClass($class); $preview = $class->showPreview($method); $preview->setContent($values->template); $preview->setPreview(); $this->template->html = (string) $preview; if ($preview->hasError()) { $this->flashMessage('emails.admin.default.variableNotExists', 'error'); } } else { $explode = explode('___', $form->getName()); $class = str_replace('_', '\\', $explode[0]); $method = $explode[1]; $class = $this->provider->getByClass($class); /** @var WebChemistry\Emails\Templating\Engine $template */ $template = call_user_func($class->getCallback($method)); $store = $template->read(); $template->getLocalFile()->rewriteSafe($values->template); @unlink($template->getCacheFile()); $template->renderToString(); if ($template->hasError()) { $template->getLocalFile()->rewriteSafe($store); $this->flashMessage('emails.admin.default.variableNotExists', 'error'); return; } // Other $class->setData($method, $form->getValues(TRUE)); $this->flashMessage('emails.admin.default.successForm'); $this->redraw(); } }