private function replaceForms() { preg_match_all("/{FORM:(.+)}/", $this->template, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $form = new Form($match[1]); $translation = $form->getCode(); $this->template = str_ireplace($match[0], $translation, $this->template); } }