/**
  * @param $value
  * @param $filter
  * @throws \Twig_Error_Runtime
  * @return \FM\BbcodeBundle\Decoda\Decoda
  */
 public function filter($value, $filter)
 {
     if (!is_string($value)) {
         throw new \Twig_Error_Runtime('The filter can be applied to strings only.');
     }
     $messages = $this->container->getParameter('fm_bbcode.config.messages');
     $messages = empty($messages) ? array() : json_decode(\file_get_contents($messages), true);
     $code = new Decoda($value, $messages);
     $current_filter = $this->filter_sets[$filter];
     $locale = $current_filter['locale'];
     $xhtml = $current_filter['xhtml'];
     if (empty($locale)) {
         // apply locale from the session
         if ('default' == $this->locale) {
             $code->setLocale($this->container->get('session')->getLocale());
             // apply locale defined in the configuration
         } else {
             // apply locale from the template
             $code->setLocale($this->locale);
         }
     } else {
         $code->setLocale($locale);
     }
     if (true === $xhtml) {
         $code->setXhtml(true);
     }
     $decoda_manager = new DecodaManager($code, $current_filter['filters'], $current_filter['hooks'], $current_filter['whitelist']);
     return $decoda_manager->getResult()->parse();
 }
 /**
  * @param mixed $entries All entries.
  * @param mixed $without Entries to be removed.
  * @return array Remaining entries of {@code $value} after removing the entries of {@code $without}.
  */
 public function BBCode($value, $locale = null)
 {
     if (!is_string($value)) {
         throw new \Twig_Error_Runtime('The filter can be applied to strings only.');
     }
     $code = new Decoda($value);
     if (empty($locale)) {
         // apply locale from the session
         if ('default' == $this->locale) {
             $code->setLocale($this->container->get('session')->getLocale());
             // apply locale defined in the configuration
         } else {
             // apply locale from the template
             $code->setLocale($this->locale);
         }
     } else {
         $code->setLocale($locale);
     }
     if (true === $this->xhtml) {
         $code->setXhtml(true);
     }
     if ($this->default == 'enabled') {
         $code->addFilter(new \DefaultFilter());
     }
     if ($this->block == 'enabled') {
         $code->addFilter(new \BlockFilter());
     }
     if ($this->code == 'enabled') {
         $code->addFilter(new \CodeFilter());
     }
     if ($this->email == 'enabled') {
         $code->addFilter(new \EmailFilter());
     }
     if ($this->image == 'enabled') {
         $code->addFilter(new \ImageFilter());
     }
     if ($this->list == 'enabled') {
         $code->addFilter(new \ListFilter());
     }
     if ($this->quote == 'enabled') {
         $code->addFilter(new \QuoteFilter());
     }
     if ($this->text == 'enabled') {
         $code->addFilter(new \TextFilter());
     }
     if ($this->url == 'enabled') {
         $code->addFilter(new \UrlFilter());
     }
     if ($this->video == 'enabled') {
         $code->addFilter(new \VideoFilter());
     }
     return $code->parse(true);
 }