Skip to content

Upgraded bundle to work with Twig3 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('stephane_collot_datetimepicker');
// Symfony/config > 4.1||5.*
Expand Down
14 changes: 8 additions & 6 deletions Twig/Extension/FormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@

use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormRenderer;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

/**
* FormExtension extends Twig with form capabilities.
*
* @author Olivier Chauvel <olivier@generation-multiple.com>
*/
class FormExtension extends \Twig_Extension
class FormExtension extends AbstractExtension
{
/**
* This property is public so that it can be accessed directly from compiled
Expand All @@ -37,11 +39,11 @@ public function __construct(FormRenderer $renderer)
/**
* {@inheritdoc}
*/
public function getFunctions()
public function getFunctions(): array
{
return array(
new \Twig_SimpleFunction('form_javascript', array($this, 'renderJavascript'), array('is_safe' => array('html'))),
new \Twig_SimpleFunction('form_stylesheet', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
new TwigFunction('form_javascript', array($this, 'renderJavascript'), array('is_safe' => array('html'))),
new TwigFunction('form_stylesheet', null, array('node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => array('html'))),
);
}

Expand All @@ -53,7 +55,7 @@ public function getFunctions()
*
* @return string
*/
public function renderJavascript(FormView $view, $prototype = false)
public function renderJavascript(FormView $view, $prototype = false): string
{
$block = $prototype ? 'javascript_prototype' : 'javascript';

Expand All @@ -63,7 +65,7 @@ public function renderJavascript(FormView $view, $prototype = false)
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return 'collot.twig.extension.form';
}
Expand Down