fix sf4 deprecated getting private container

This commit is contained in:
Tchama 2020-07-16 15:51:05 +02:00
parent 3c5082dafb
commit 59bf662886
2 changed files with 14 additions and 1 deletions

View File

@ -108,6 +108,8 @@ services:
chill.custom_field.twig.custom_fields_rendering: chill.custom_field.twig.custom_fields_rendering:
class: Chill\CustomFieldsBundle\Templating\Twig\CustomFieldRenderingTwig class: Chill\CustomFieldsBundle\Templating\Twig\CustomFieldRenderingTwig
arguments:
- "@chill.custom_field.helper"
calls: calls:
- [setContainer, ["@service_container"]] - [setContainer, ["@service_container"]]
tags: tags:

View File

@ -22,6 +22,7 @@
namespace Chill\CustomFieldsBundle\Templating\Twig; namespace Chill\CustomFieldsBundle\Templating\Twig;
use Chill\CustomFieldsBundle\Service\CustomFieldsHelper;
use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\Container;
@ -45,6 +46,16 @@ class CustomFieldRenderingTwig extends \Twig_Extension implements ContainerAware
'label_layout' => 'ChillCustomFieldsBundle:CustomField:render_label.html.twig' 'label_layout' => 'ChillCustomFieldsBundle:CustomField:render_label.html.twig'
); );
/**
* @var CustomFieldsHelper
*/
private $customFieldsHelper;
public function __construct(CustomFieldsHelper $customFieldsHelper)
{
$this->customFieldsHelper = $customFieldsHelper;
}
/* /*
* (non-PHPdoc) * (non-PHPdoc)
* @see \Symfony\Component\DependencyInjection\ContainerAwareInterface::setContainer() * @see \Symfony\Component\DependencyInjection\ContainerAwareInterface::setContainer()
@ -87,7 +98,7 @@ class CustomFieldRenderingTwig extends \Twig_Extension implements ContainerAware
public function isEmptyValue($fields, CustomField $customField) public function isEmptyValue($fields, CustomField $customField)
{ {
return $this->container->get('chill.custom_field.helper') return $this->customFieldsHelper
->isEmptyValue($fields, $customField); ->isEmptyValue($fields, $customField);
} }