Code Duplication    Length = 20-22 lines in 2 locations

src/AdminBundle/Controller/CmsBlockController.php 1 location

@@ 129-150 (lines=22) @@
126
     * @param string $key
127
     * @param string $val
128
     */
129
    public function cmsFilters(QueryBuilder $qb, $key, $val)
130
    {
131
        if (empty($val)) {
132
            return;
133
        }
134
135
        switch ($key) {
136
        case 't.alias':
137
            $qb->andWhere($qb->expr()->like('t.alias', ':alias'));
138
            $qb->setParameter('alias', "%$val%");
139
            break;
140
        case 't.name':
141
            $qb->andWhere($qb->expr()->like('t.name', ':name'));
142
            $qb->setParameter('name', "%$val%");
143
            break;
144
        case 't.updatedAt':
145
            $date = date("Y-m-d", strtotime($val));
146
            $qb->andWhere($qb->expr()->gt('t.updatedAt', "'$date 00:00:00'"));
147
            $qb->andWhere($qb->expr()->lt('t.updatedAt', "'$date 23:59:59'"));
148
            break;
149
        }
150
    }
151
}
152

src/AdminBundle/Controller/MailTemplateController.php 1 location

@@ 126-145 (lines=20) @@
123
     * @param $key
124
     * @param $val
125
     */
126
    public function templateFilters(QueryBuilder $qb, $key, $val)
127
    {
128
        if (!$val) {
129
            return;
130
        }
131
132
        switch ($key) {
133
        case 't.alias':
134
            $qb->andWhere($qb->expr()->like('t.alias', ':alias'))->setParameter('alias', "%$val%");
135
            break;
136
        case 't.subject':
137
            $qb->andWhere($qb->expr()->like('t.subject', ':subject'))->setParameter('subject', "%$val%");
138
            break;
139
        case 't.updatedAt':
140
            $date = date("Y-m-d", strtotime($val));
141
            $qb->andWhere($qb->expr()->gt('t.updatedAt', "'$date 00:00:00'"));
142
            $qb->andWhere($qb->expr()->lt('t.updatedAt', "'$date 23:59:59'"));
143
            break;
144
        }
145
    }
146
}
147