1 | <?php |
||||||
2 | declare(strict_types=1); |
||||||
3 | /** |
||||||
4 | */ |
||||||
5 | |||||||
6 | namespace CommerceLeague\ActiveCampaign\Model\ResourceModel\Magento; |
||||||
7 | |||||||
8 | use CommerceLeague\ActiveCampaign\Setup\SchemaInterface; |
||||||
9 | use Magento\Framework\DB\Select; |
||||||
10 | use Magento\Newsletter\Model\ResourceModel\Subscriber\Collection as ExtendSubscriberCollection; |
||||||
11 | |||||||
12 | /** |
||||||
13 | * Class SubscriberCollection |
||||||
14 | * @codeCoverageIgnore |
||||||
15 | */ |
||||||
16 | class SubscriberCollection extends ExtendSubscriberCollection |
||||||
17 | { |
||||||
18 | /** |
||||||
19 | * @inheritDoc |
||||||
20 | */ |
||||||
21 | protected function _initSelect() |
||||||
22 | { |
||||||
23 | parent::_initSelect(); |
||||||
24 | |||||||
25 | $this->getSelect()->joinLeft( |
||||||
26 | ['ac_contact' => $this->_resource->getTable(SchemaInterface::CONTACT_TABLE)], |
||||||
0 ignored issues
–
show
|
|||||||
27 | 'ac_contact.email = main_table.subscriber_email', |
||||||
28 | ['ac_contact.activecampaign_id'] |
||||||
29 | ); |
||||||
30 | } |
||||||
31 | |||||||
32 | /** |
||||||
33 | * @return SubscriberCollection |
||||||
34 | */ |
||||||
35 | public function excludeCustomers(): self |
||||||
36 | { |
||||||
37 | $this->getSelect()->where('main_table.customer_id = 0'); |
||||||
38 | return $this; |
||||||
39 | } |
||||||
40 | |||||||
41 | /** |
||||||
42 | * @param string $email |
||||||
43 | * @return SubscriberCollection |
||||||
44 | */ |
||||||
45 | public function addEmailFilter(string $email): self |
||||||
46 | { |
||||||
47 | $this->getSelect()->where('main_table.subscriber_email = ?', $email); |
||||||
48 | return $this; |
||||||
49 | } |
||||||
50 | |||||||
51 | /** |
||||||
52 | * @return SubscriberCollection |
||||||
53 | */ |
||||||
54 | public function addContactOmittedFilter(): self |
||||||
55 | { |
||||||
56 | $this->getSelect()->where('ac_contact.activecampaign_id IS NULL'); |
||||||
57 | return $this; |
||||||
58 | } |
||||||
59 | |||||||
60 | /** |
||||||
61 | * @return array |
||||||
62 | */ |
||||||
63 | public function getAllEmails(): array |
||||||
64 | { |
||||||
65 | $emailsSelect = clone $this->getSelect(); |
||||||
66 | $emailsSelect->reset(Select::ORDER); |
||||||
67 | $emailsSelect->reset(Select::LIMIT_COUNT); |
||||||
68 | $emailsSelect->reset(Select::LIMIT_OFFSET); |
||||||
69 | $emailsSelect->reset(Select::COLUMNS); |
||||||
70 | $emailsSelect->columns('subscriber_email', 'main_table'); |
||||||
0 ignored issues
–
show
The call to
Magento\Framework\DB\Select::columns() has too many arguments starting with 'subscriber_email' .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.
Loading history...
|
|||||||
71 | |||||||
72 | return $this->getConnection()->fetchCol($emailsSelect, $this->_bindParams); |
||||||
73 | } |
||||||
74 | } |
||||||
75 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.