Completed
Push — master ( 6e92d2...d7f3a5 )
by
unknown
109:07 queued 86:32
created

AbstractArticleTagAdminListConfigurator.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\ArticleBundle\AdminList;
4
5
use Doctrine\ORM\EntityManager;
6
use Doctrine\ORM\EntityManagerInterface;
7
use Doctrine\ORM\QueryBuilder;
8
use Kunstmaan\AdminBundle\Helper\Security\Acl\AclHelper;
9
use Kunstmaan\AdminListBundle\AdminList\Configurator\AbstractDoctrineORMAdminListConfigurator;
10
use Kunstmaan\AdminListBundle\AdminList\FilterType\ORM\StringFilterType;
11
12
/**
13
 * The AdminList configurator for the AbstractArticleAuthor
14
 */
15 View Code Duplication
class AbstractArticleTagAdminListConfigurator extends AbstractDoctrineORMAdminListConfigurator
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

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