/** * @param Decoda $code * @param $hook * @return Decoda */ protected function apply_hook(Decoda $code, $hook) { if (isset(static::$extra_hooks[$hook])) { $extra_hook = static::$extra_hooks[$hook] instanceof \DecodaHook ? static::$extra_hooks[$hook] : new static::$extra_hooks[$hook](); $code->addFilter($extra_hook); return $code; } switch ($hook) { case 'censor': $code->addHook(new \CensorHook()); break; case 'clickable': $code->addHook(new \ClickableHook()); break; case 'emoticon': $code->addHook(new \EmoticonHook()); break; } return $code; }
/** * @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); }