Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
<?php
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\CoreBundle\Twig\Node;
use Symfony\Component\Translation\TranslatorInterface;
class TemplateBoxNode extends \Twig_Node
{
/**
* @var int
*/
protected $enabled;
/**
* @var TranslatorInterface
*/
protected $translator;
/**
* @param \Twig_Node_Expression $message Node message to display
* @param \Twig_Node_Expression $translationBundle Node translation bundle to use for display
* @param int $enabled Is Symfony debug enabled?
* @param TranslatorInterface $translator Symfony Translator service
* @param null|string $lineno Symfony template line number
* @param null $tag Symfony tag name
*/
public function __construct(\Twig_Node_Expression $message, \Twig_Node_Expression $translationBundle = null, $enabled, TranslatorInterface $translator, $lineno, $tag = null)
{
$this->enabled = $enabled;
$this->translator = $translator;
$nodes = array('message' => $message);
if ($translationBundle) {
$nodes['translationBundle'] = $translationBundle;
}
parent::__construct($nodes, array(), $lineno, $tag);
}
/**
* {@inheritdoc}
*/
public function compile(\Twig_Compiler $compiler)
{
$compiler
->addDebugInfo($this);
if (!$this->enabled) {
$compiler->write("// token for sonata_template_box, however the box is disabled\n");
return;
}
$value = $this->getNode('message')->getAttribute('value');
$translationBundle = null;
if ($this->hasNode('translationBundle')) {
$translationBundle = $this->getNode('translationBundle');
}
if ($translationBundle) {
$translationBundle = $translationBundle->getAttribute('value');
}
$message = <<<CODE
"<div class='alert alert-default alert-info'>
<strong>{$this->translator->trans($value, array(), $translationBundle)}</strong>
<div>{$this->translator->trans('sonata_core_template_box_file_found_in', array(), 'SonataCoreBundle')} <code>{\$this->getTemplateName()}</code>.</div>
</div>"
CODE;
$compiler
->write("echo $message;");
}
}