Esempio n. 1
0
 /**
  * @param ViewContext $viewContext
  * @param string $formName
  * @return Form|NULL
  */
 public function getFormFromTemplateFile(ViewContext $viewContext, $formName = 'form')
 {
     $templatePathAndFilename = $viewContext->getTemplatePathAndFilename();
     if (FALSE === file_exists($templatePathAndFilename)) {
         return NULL;
     }
     $section = $viewContext->getSectionName();
     $variables = $viewContext->getVariables();
     $extensionName = $viewContext->getExtensionName();
     $variableCheck = json_encode($variables);
     $cacheKey = md5($templatePathAndFilename . $formName . $extensionName . $section . $variableCheck);
     if (FALSE === isset(self::$cache[$cacheKey])) {
         try {
             $exposedView = $this->getPreparedExposedTemplateView($viewContext);
             self::$cache[$cacheKey] = $exposedView->getForm($section, $formName);
         } catch (\RuntimeException $error) {
             $this->debug($error);
             /** @var Form $form */
             self::$cache[$cacheKey] = $this->objectManager->get(FluxPackageFactory::getPackageWithFallback($extensionName)->getImplementation(FluxPackage::IMPLEMENTATION_FORM));
             self::$cache[$cacheKey]->createField('UserFunction', 'error')->setFunction('FluidTYPO3\\Flux\\UserFunction\\ErrorReporter->renderField')->setArguments(array($error));
         }
     }
     return self::$cache[$cacheKey];
 }