mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
Render for title
This commit is contained in:
parent
978f2eea5e
commit
8fa75e2dd6
@ -25,6 +25,7 @@ use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface;
|
|||||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\HttpFoundation\RequestStack;
|
use Symfony\Component\HttpFoundation\RequestStack;
|
||||||
|
use Symfony\Bundle\TwigBundle\TwigEngine;
|
||||||
|
|
||||||
class CustomFieldTitle implements CustomFieldInterface
|
class CustomFieldTitle implements CustomFieldInterface
|
||||||
{
|
{
|
||||||
@ -34,9 +35,16 @@ class CustomFieldTitle implements CustomFieldInterface
|
|||||||
|
|
||||||
private $requestStack;
|
private $requestStack;
|
||||||
|
|
||||||
public function __construct(RequestStack $requestStack)
|
/**
|
||||||
|
*
|
||||||
|
* @var TwigEngine
|
||||||
|
*/
|
||||||
|
private $templating;
|
||||||
|
|
||||||
|
public function __construct(RequestStack $requestStack, TwigEngine $templating)
|
||||||
{
|
{
|
||||||
$this->requestStack = $requestStack;
|
$this->requestStack = $requestStack;
|
||||||
|
$this->templating = $templating;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
|
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
|
||||||
@ -52,8 +60,14 @@ class CustomFieldTitle implements CustomFieldInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function render($value, CustomField $customField)
|
public function render($value, CustomField $customField)
|
||||||
{
|
{
|
||||||
return $value;
|
return $this->templating
|
||||||
|
->render('ChillCustomFieldsBundle:CustomFieldsRendering:title.html.twig',
|
||||||
|
array(
|
||||||
|
'title' => $customField->getName(),
|
||||||
|
'type' => $customField->getOptions()[self::TYPE]
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function serialize($value, CustomField $customField)
|
public function serialize($value, CustomField $customField)
|
||||||
|
@ -68,6 +68,7 @@ services:
|
|||||||
class: Chill\CustomFieldsBundle\CustomFields\CustomFieldTitle
|
class: Chill\CustomFieldsBundle\CustomFields\CustomFieldTitle
|
||||||
arguments:
|
arguments:
|
||||||
- "@request_stack"
|
- "@request_stack"
|
||||||
|
- "@templating"
|
||||||
tags:
|
tags:
|
||||||
- { name: 'chill.custom_field', type: 'title' }
|
- { name: 'chill.custom_field', type: 'title' }
|
||||||
|
|
||||||
|
5
Resources/views/CustomFieldsRendering/title.html.twig
Normal file
5
Resources/views/CustomFieldsRendering/title.html.twig
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{% if type == "title"%}
|
||||||
|
<h2>{{ title[app.request.locale] }}</h2>
|
||||||
|
{% else %}
|
||||||
|
<h3>{{ title[app.request.locale] }}</h3>
|
||||||
|
{% endif %}
|
Loading…
x
Reference in New Issue
Block a user