Code Duplication    Length = 76-76 lines in 2 locations

src/Kunstmaan/ArticleBundle/AdminList/AbstractArticleCategoryAdminListConfigurator.php 1 location

@@ 14-89 (lines=76) @@
11
/**
12
 * The AdminList configurator for the AbstractArticleAuthor
13
 */
14
class AbstractArticleCategoryAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator
15
{
16
    /**
17
     * @param EntityManagerInterface $em        The entity manager
18
     * @param AclHelper              $aclHelper The ACL helper
19
     */
20
    public function __construct(EntityManagerInterface $em, AclHelper $aclHelper)
21
    {
22
        parent::__construct($em, $aclHelper);
23
    }
24
25
    /**
26
     * Return current bundle name.
27
     *
28
     * @return string
29
     */
30
    public function getBundleName()
31
    {
32
        return 'KunstmaanArticleBundle';
33
    }
34
35
    /**
36
     * Return current entity name.
37
     *
38
     * @return string
39
     */
40
    public function getEntityName()
41
    {
42
        return 'AbstractArticleCategory';
43
    }
44
45
    /**
46
     * Configure filters
47
     */
48
    public function buildFilters()
49
    {
50
        $this->addFilter('name', new StringFilterType('name'), 'article.category.list.filter.name');
51
    }
52
53
    /**
54
     * Configure the visible columns
55
     */
56
    public function buildFields()
57
    {
58
        $this->addField('name', 'article.category.list.header.name', true);
59
    }
60
61
    public function adaptQueryBuilder(QueryBuilder $queryBuilder)
62
    {
63
        $queryBuilder->orderBy('b.name', 'ASC');
64
    }
65
66
    /**
67
     * Overwrite the parent function. By adding the TranslationWalker, we can order by the translated fields.
68
     *
69
     * @return \Doctrine\ORM\Query|null
70
     */
71
    public function getQuery()
72
    {
73
        $query = parent::getQuery();
74
75
        if (!\is_null($query)) {
76
            $query->setHint(
77
                \Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
78
                'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
79
            );
80
            $query->useQueryCache(false);
81
        }
82
83
        return $query;
84
    }
85
}
86

src/Kunstmaan/ArticleBundle/AdminList/AbstractArticleTagAdminListConfigurator.php 1 location

@@ 14-89 (lines=76) @@
11
/**
12
 * The AdminList configurator for the AbstractArticleAuthor
13
 */
14
class AbstractArticleTagAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator
15
{
16
    /**
17
     * @param EntityManagerInterface $em        The entity manager
18
     * @param AclHelper              $aclHelper The ACL helper
19
     */
20
    public function __construct(EntityManagerInterface $em, AclHelper $aclHelper)
21
    {
22
        parent::__construct($em, $aclHelper);
23
    }
24
25
    /**
26
     * Return current bundle name.
27
     *
28
     * @return string
29
     */
30
    public function getBundleName()
31
    {
32
        return 'KunstmaanArticleBundle';
33
    }
34
35
    /**
36
     * Return current entity name.
37
     *
38
     * @return string
39
     */
40
    public function getEntityName()
41
    {
42
        return 'AbstractArticleTag';
43
    }
44
45
    /**
46
     * Configure filters
47
     */
48
    public function buildFilters()
49
    {
50
        $this->addFilter('name', new StringFilterType('name'), 'article.tag.list.filter.name');
51
    }
52
53
    /**
54
     * Configure the visible columns
55
     */
56
    public function buildFields()
57
    {
58
        $this->addField('name', 'article.tag.list.header.name', true);
59
    }
60
61
    public function adaptQueryBuilder(QueryBuilder $queryBuilder)
62
    {
63
        $queryBuilder->orderBy('b.name', 'ASC');
64
    }
65
66
    /**
67
     * Overwrite the parent function. By adding the TranslationWalker, we can order by the translated fields.
68
     *
69
     * @return \Doctrine\ORM\Query|null
70
     */
71
    public function getQuery()
72
    {
73
        $query = parent::getQuery();
74
75
        if (!\is_null($query)) {
76
            $query->setHint(
77
                \Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER,
78
                'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker'
79
            );
80
            $query->useQueryCache(false);
81
        }
82
83
        return $query;
84
    }
85
}
86