<commit_before><?php

namespace FM\ElfinderBundle\Twig\Extension;

use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Class FMElfinderTinymceExtension
 * @package FM\ElfinderBundle\Twig\Extension
 */
class FMElfinderTinymceExtension extends \Twig_Extension
{
    /**
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
     */
    protected $container;

    /**
     * @param ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * (non-PHPdoc)
     * @see Twig_Extension::getFilters()
     * @return array
     */
    public function getFunctions()
    {
        return array(
            'elfinder_tinymce_init' => new \Twig_Function_Method($this, 'tinymce', array('is_safe' => array('html'))),
            'elfinder_tinymce_init4' => new \Twig_Function_Method($this, 'tinymce4', array('is_safe' => array('html')))
        );
    }

    /**
     * @return mixed
     */
    public function tinymce()
    {
        return $this->container->get('templating')->render('FMElfinderBundle:Elfinder/helper:_tinymce.html.twig');
    }

    /**
     * @return mixed
     */
    public function tinymce4()
    {
        return $this->container->get('templating')->render('FMElfinderBundle:Elfinder/helper:_tinymce4.html.twig');
    }

    /**
     * (non-PHPdoc)
     * @see Twig_ExtensionInterface::getName()
     */
    public function getName()
    {
        return 'fm_tinymce_init';
    }
}<commit_msg>added ability for multiple instances of elfinder with different configurations<commit_after><?php

namespace FM\ElfinderBundle\Twig\Extension;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Twig_Error_Runtime;
use Twig_Extension;

/**
 * Class FMElfinderTinymceExtension
 * @package FM\ElfinderBundle\Twig\Extension
 */
class FMElfinderTinymceExtension extends Twig_Extension
{
    /**
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
     */
    protected $container;

    /**
     * @param ContainerInterface $container
     */
    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    /**
     * (non-PHPdoc)
     * @see Twig_Extension::getFilters()
     * @return array
     */
    public function getFunctions()
    {
        return array(
            'elfinder_tinymce_init' => new \Twig_Function_Method($this, 'tinymce', array('is_safe' => array('html'))),
            'elfinder_tinymce_init4' => new \Twig_Function_Method($this, 'tinymce4', array('is_safe' => array('html')))
        );
    }

    /**
     * @param string $instance
     * @param array $parameters
     * @throws \Twig_Error_Runtime
     * @return mixed
     */
    public function tinymce($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0'))
    {
        if (!is_string($instance)) {
            throw new Twig_Error_Runtime('The filter can be applied to strings only.');
        }

        return $this->container->get('templating')->render('FMElfinderBundle:Elfinder/helper:_tinymce.html.twig',
            array(
                'instance' => $instance,
                'width'    => $parameters['width'],
                'height'   => $parameters['height'],
                'title'    => $parameters['title']
            ));
    }

    /**
     * @param string $instance
     * @param array $parameters
     * @throws \Twig_Error_Runtime
     * @return mixed
     */
    public function tinymce4($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0'))
    {
        if (!is_string($instance)) {
            throw new Twig_Error_Runtime('The filter can be applied to strings only.');
        }

        return $this->container->get('templating')->render('FMElfinderBundle:Elfinder/helper:_tinymce4.html.twig',
            array(
                'instance' => $instance,
                'width'    => $parameters['width'],
                'height'   => $parameters['height'],
                'title'    => $parameters['title']
            ));
    }

    /**
     * (non-PHPdoc)
     * @see Twig_ExtensionInterface::getName()
     */
    public function getName()
    {
        return 'fm_tinymce_init';
    }

}
{'fraction_non_alphanumeric': 0.1342386464826358, 'fraction_numerical': 0.005342831700801425, 'mean_word_length': 2.2915750915750914, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3621881', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1292, 'n_words': 229}