twigRepository = $twigRepository; $this->templateRepository = $templateRepository; $this->twigUpdateQuery = $twigUpdateQuery; } /** * @param TwigView $view [description] * * @return int|bool [description] */ public function create(TwigView $view, ?int $templateId = null) { $twig = new Twig(); $twig->setName($view->name); $twig->setExportType($view->exportType); $twig->setContent($view->content); $entity = $this->twigRepository->save($twig); if (!$entity) { return false; } $variablesAndInputsUpdated = $this->twigUpdateQuery->updateVariablesAndInputs($entity); if (!empty($templateId)) { $template = $this->templateRepository->findById($templateId); if (!empty($template)) { $template->setTwig($entity); $this->templateRepository->save($template); } } return $entity->getId(); } }