Issues (3627)

MauticFocusBundle/Entity/FocusRepository.php (1 issue)

1
<?php
2
3
/*
4
 * @copyright   2016 Mautic, Inc. All rights reserved
5
 * @author      Mautic, Inc
6
 *
7
 * @link        https://mautic.org
8
 *
9
 * @license     GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
10
 */
11
12
namespace MauticPlugin\MauticFocusBundle\Entity;
13
14
use Mautic\CoreBundle\Entity\CommonRepository;
15
16
class FocusRepository extends CommonRepository
17
{
18
    /**
19
     * @param $formId
20
     *
21
     * @return array
22
     */
23
    public function findByForm($formId)
24
    {
25
        return $this->findBy(
26
            [
27
                'form' => (int) $formId,
28
            ]
29
        );
30
    }
31
32
    /**
33
     * Get a list of entities.
34
     *
35
     * @return Paginator
36
     */
37
    public function getEntities(array $args = [])
38
    {
39
        $alias = $this->getTableAlias();
40
41
        $q = $this->_em
42
            ->createQueryBuilder()
43
            ->select($alias)
44
            ->from('MauticFocusBundle:Focus', $alias, $alias.'.id');
45
46
        if (empty($args['iterator_mode'])) {
47
            $q->leftJoin($alias.'.category', 'c');
48
        }
49
50
        $args['qb'] = $q;
51
52
        return parent::getEntities($args);
53
    }
54
55
    /**
56
     * @param \Doctrine\ORM\QueryBuilder|\Doctrine\DBAL\Query\QueryBuilder $q
57
     * @param                                                              $filter
58
     *
59
     * @return array
60
     */
61
    protected function addCatchAllWhereClause($q, $filter)
62
    {
63
        return $this->addStandardCatchAllWhereClause($q, $filter, ['f.name', 'f.website']);
64
    }
65
66
    /**
67
     * @param \Doctrine\ORM\QueryBuilder|\Doctrine\DBAL\Query\QueryBuilder $q
68
     * @param                                                              $filter
69
     *
70
     * @return array
71
     */
72
    protected function addSearchCommandWhereClause($q, $filter)
73
    {
74
        return $this->addStandardSearchCommandWhereClause($q, $filter);
75
    }
76
77
    /**
78
     * @return array
79
     */
80
    public function getSearchCommands()
81
    {
82
        return $this->getStandardSearchCommands();
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    protected function getDefaultOrder()
89
    {
90
        return [
91
            [$this->getTableAlias().'.name', 'ASC'],
92
        ];
93
    }
94
95
    /**
96
     * {@inheritdoc}
97
     *
98
     * @return string
99
     */
100
    public function getTableAlias()
101
    {
102
        return 'f';
103
    }
104
105
    /**
106
     * @return array
107
     */
108
    public function getFocusList($currentId)
0 ignored issues
show
The parameter $currentId is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

108
    public function getFocusList(/** @scrutinizer ignore-unused */ $currentId)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
109
    {
110
        $q = $this->createQueryBuilder('f');
111
        $q->select('partial f.{id, name, description}')->orderBy('f.name');
112
113
        return $q->getQuery()->getArrayResult();
114
    }
115
}
116