for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the SludioHelperBundle package.
*
* @author Dāvis Zālītis <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sludio\HelperBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class TemplatingPass implements CompilerPassInterface
{
* {@inheritdoc}
* @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
public function process(ContainerBuilder $container)
$resources = $container->getParameter('twig.form.resources');
$forms = [
'sludio_helper.translatable.enabled' => 'sludio_helper.translatable.template',
'sludio_helper.captcha.enabled' => 'sludio_helper.captcha.client.recaptcha.template',
];
foreach ($forms as $check => $form) {
if ($container->hasParameter($check) && $container->getParameter($check) === true && $container->hasParameter($form) && false !== ($template = $container->getParameter($form))) {
if (!\in_array($template, $resources, false)) {
$resources[] = $template;
}
$container->setParameter('twig.form.resources', $resources);