Piwik\Twig::addFilter_notification PHP Method

addFilter_notification() protected method

protected addFilter_notification ( )
    protected function addFilter_notification()
    {
        $twigEnv = $this->getTwigEnvironment();
        $notificationFunction = new Twig_SimpleFilter('notification', function ($message, $options) use($twigEnv) {
            $template = '<div style="display:none" data-role="notification" ';
            foreach ($options as $key => $value) {
                if (ctype_alpha($key)) {
                    $template .= sprintf('data-%s="%s" ', $key, twig_escape_filter($twigEnv, $value, 'html_attr'));
                }
            }
            $template .= '>';
            if (!empty($options['raw'])) {
                $template .= $message;
            } else {
                $template .= twig_escape_filter($twigEnv, $message, 'html');
            }
            $template .= '</div>';
            return $template;
        }, array('is_safe' => array('html')));
        $this->twig->addFilter($notificationFunction);
    }