/** * @param array $row * @return ViewContext */ public function getViewContext(array $row, RequestInterface $request = NULL) { if (FALSE === $this->viewContext instanceof ViewContext) { // Note: we do *not* store a local property because we do *not* want this function // to re-use the ViewContext unless explicitly set from the outside or initialised // by a sub-class. $context = new ViewContext($this->getTemplatePathAndFilename($row), $this->getControllerPackageNameFromRecord($row), $this->getControllerNameFromRecord($row), $request); $context->setSectionName($this->getConfigurationSectionName($row)); $context->setTemplatePaths(new TemplatePaths($this->getTemplatePaths($row))); $context->setVariables($this->getViewVariables($row)); return $context; } return $this->viewContext; }
/** * @param string $templateName * @param array $variables */ protected function assertFluxTemplateLoadsWithoutErrors($templateName, $variables = array()) { if (0 === count($variables)) { $variables = array('row' => Records::$contentRecordWithoutParentAndWithoutChildren); } $templatePathAndFilename = $this->getAbsoluteFixtureTemplatePathAndFilename($templateName); $service = $this->createFluxServiceInstance(); $viewContext = new ViewContext($templatePathAndFilename, 'Flux'); $viewContext->setVariables($variables); $viewContext->setSectionName('Configuration'); $form = $service->getFormFromTemplateFile($viewContext); if (NULL !== $form) { $this->assertInstanceOf('FluidTYPO3\\Flux\\Form', $form); $this->assertIsArray($form->build()); } }
/** * @param ProviderInterface $provider * @param array $row * @param Form $form * @return string|NULL */ protected function renderPreviewSection(ProviderInterface $provider, array $row, Form $form = NULL) { $templatePathAndFilename = $provider->getTemplatePathAndFilename($row); if (NULL === $templatePathAndFilename) { return NULL; } $extensionKey = $provider->getExtensionKey($row); $paths = $provider->getTemplatePaths($row); $flexformVariables = $provider->getFlexFormValues($row); $templateVariables = $provider->getTemplateVariables($row); $variables = RecursiveArrayUtility::merge($templateVariables, $flexformVariables); $variables['row'] = $row; $variables['record'] = $row; if (TRUE === is_object($form)) { $formLabel = $form->getLabel(); $label = LocalizationUtility::translate($formLabel, $extensionKey); $variables['label'] = $label; } $templatePaths = new TemplatePaths($paths); $viewContext = new ViewContext($templatePathAndFilename, $extensionKey, self::CONTROLLER_NAME); $viewContext->setTemplatePaths($templatePaths); $viewContext->setVariables($variables); $view = $this->configurationService->getPreparedExposedTemplateView($viewContext); $existingContentObject = $this->configurationManager->getContentObject(); $contentObject = new ContentObjectRenderer(); $contentObject->start($row, $provider->getTableName($row)); $this->configurationManager->setContentObject($contentObject); $previewContent = $view->renderStandaloneSection(self::PREVIEW_SECTION, $variables, TRUE); $this->configurationManager->setContentObject($existingContentObject); $previewContent = trim($previewContent); return $previewContent; }
/** * @param array $row * @return Grid */ public function getGrid(array $row) { if (NULL !== $this->grid) { return $this->grid; } $cacheKey = $this->getCacheKeyForStoredVariable($row, 'grid'); if (FALSE === isset(self::$cache[$cacheKey])) { $class = get_class($this); $controllerName = substr(substr($class, strrpos($class, '\\') + 1), 0, -8); $templatePathAndFilename = $this->getTemplatePathAndFilename($row); $section = $this->getConfigurationSectionName($row); $gridName = 'grid'; $paths = $this->getTemplatePaths($row); $extensionKey = $this->getExtensionKey($row); $extensionName = ExtensionNamingUtility::getExtensionName($extensionKey); $variables = $this->getViewVariables($row); $viewContext = new ViewContext($templatePathAndFilename, $extensionName, $controllerName); $viewContext->setTemplatePaths(new TemplatePaths($paths)); $viewContext->setSectionName($section); $viewContext->setVariables($variables); $grid = $this->configurationService->getGridFromTemplateFile($viewContext, $gridName); self::$cache[$cacheKey] = $grid; } return self::$cache[$cacheKey]; }