public function getExtensions() { $fieldBlockRenderer = new FieldBlockRenderer(); $fieldBlockRenderer->setBaseTemplate($this->getTemplatePath('base.html.twig')); $fieldBlockRenderer->setFieldDefinitionEditResources([['template' => $this->getTemplatePath('fields_override1.html.twig'), 'priority' => 10], ['template' => $this->getTemplatePath('fields_default.html.twig'), 'priority' => 0], ['template' => $this->getTemplatePath('fields_override2.html.twig'), 'priority' => 20]]); return [new FieldEditRenderingExtension($fieldBlockRenderer)]; }
public function getExtensions() { $configResolver = $this->getConfigResolverMock(); $fieldBlockRenderer = new FieldBlockRenderer(); $fieldBlockRenderer->setBaseTemplate($this->getTemplatePath('base.html.twig')); $fieldBlockRenderer->setFieldViewResources(array(array('template' => $this->getTemplatePath('fields_override1.html.twig'), 'priority' => 10), array('template' => $this->getTemplatePath('fields_default.html.twig'), 'priority' => 0), array('template' => $this->getTemplatePath('fields_override2.html.twig'), 'priority' => 20))); $fieldBlockRenderer->setFieldDefinitionViewResources(array(array('template' => $this->getTemplatePath('settings_override1.html.twig'), 'priority' => 10), array('template' => $this->getTemplatePath('settings_default.html.twig'), 'priority' => 0), array('template' => $this->getTemplatePath('settings_override2.html.twig'), 'priority' => 20))); return array(new FieldRenderingExtension($fieldBlockRenderer, $this->getContentTypeServiceMock(), $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\FieldType\\View\\ParameterProviderRegistryInterface'), new TranslationHelper($configResolver, $this->getMock('eZ\\Publish\\API\\Repository\\ContentService'), array(), $this->getMock('Psr\\Log\\LoggerInterface')))); }
public function renderFieldDefinitionEdit(FieldDefinitionData $fieldDefinitionData, array $params = []) { $params += ['data' => $fieldDefinitionData]; try { return $this->fieldBlockRenderer->renderFieldDefinitionEdit($fieldDefinitionData->fieldDefinition, $params); } catch (MissingFieldBlockException $e) { // Silently fail on purpose. // If there is no template block for current field definition, there might not be anything specific to add. return ''; } }
/** * Renders the HTML for a given field. * * @param \eZ\Publish\API\Repository\Values\Content\Content $content * @param string $fieldIdentifier Identifier for the field we want to render * @param array $params An array of parameters to pass to the field view * * @return string The HTML markup * * @throws InvalidArgumentException */ public function renderField(Content $content, $fieldIdentifier, array $params = []) { $field = $this->translationHelper->getTranslatedField($content, $fieldIdentifier, isset($params['lang']) ? $params['lang'] : null); if (!$field instanceof Field) { throw new InvalidArgumentException('$fieldIdentifier', "'{$fieldIdentifier}' field not present on content #{$content->contentInfo->id} '{$content->contentInfo->name}'"); } $params = $this->getRenderFieldBlockParameters($content, $field, $params); $fieldTypeIdentifier = $this->getFieldTypeIdentifier($content, $field); return $this->fieldBlockRenderer->renderContentFieldView($field, $fieldTypeIdentifier, $params); }
/** * Renders the HTML for a given field. * * @throws InvalidArgumentException * * @param \Netgen\EzPlatformSiteApi\API\Values\Field $field * @param array $params An array of parameters to pass to the field view * * @return string The HTML markup */ public function renderField(Field $field, array $params = []) { $params = $this->getRenderFieldBlockParameters($field, $params); return $this->fieldBlockRenderer->renderContentFieldView($field->innerField, $field->fieldTypeIdentifier, $params); }