Sonata管理员突出显示字段消息

时间:2017-12-29 10:51:35

标签: sonata-admin

概念:管理员想知道有多少人在评论列表中使用了坏词(咒骂词),管理员输入了一些客户常用的词语。

我使用sonata admin作为我的后端。我正在使用直接listMapper显示如下所示的列表。

$listMapper->add('message');

在我的留言栏中有一条消息:"我今天真的很开心"。

我有数组中的单词列表,我需要在列表页面中突出显示。

enter image description here

现在在列表页面中,我需要Happy作为亮点,因为它在我拥有的数组中,概念就像发誓的话。

在前端树枝文件中我需要相同的功能,我需要制作它***而不是我通过扩展实现的咒骂词。

{{ review.message|truncate(150, true, ' ...')|check_word_exist_in_array_and_replace(swearWordsList,'***') }}

扩展名是:

new \Twig_SimpleFilter('check_word_exist_in_array_and_replace', array($this, 'checkWordExistInArrayAndReplace')),

public function checkWordExistInArrayAndReplace($string,$array,$replace_str)
{
    foreach ($array as $element) {
        $string =  str_ireplace($element,$replace_str,$string);            
    }
    return $string;
}

0 个答案:

没有答案
相关问题