commerceleague /
magento2-module-activecampaign
| 1 | <?php |
||
| 2 | declare(strict_types=1); |
||
| 3 | /** |
||
| 4 | */ |
||
| 5 | |||
| 6 | namespace CommerceLeague\ActiveCampaign\Model\ResourceModel\Customer; |
||
| 7 | |||
| 8 | use CommerceLeague\ActiveCampaign\Setup\SchemaInterface; |
||
| 9 | use Magento\Customer\Model\ResourceModel\Customer\Collection as ExtendCustomerCollection; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Class Collection |
||
| 13 | * @codeCoverageIgnore |
||
| 14 | */ |
||
| 15 | class Collection extends ExtendCustomerCollection |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @inheritDoc |
||
| 19 | */ |
||
| 20 | protected function _initSelect() |
||
| 21 | { |
||
| 22 | parent::_initSelect(); |
||
| 23 | |||
| 24 | $this->getSelect()->joinLeft( |
||
| 25 | ['ac_contact' => $this->_resource->getTableName(SchemaInterface::CONTACT_TABLE)], |
||
|
0 ignored issues
–
show
|
|||
| 26 | 'ac_contact.email = e.email', |
||
| 27 | ['ac_contact.activecampaign_id'] |
||
| 28 | ); |
||
| 29 | |||
| 30 | $this->getSelect()->joinLeft( |
||
| 31 | ['ac_customer' => $this->_resource->getTableName(SchemaInterface::CUSTOMER_TABLE)], |
||
| 32 | 'ac_customer.magento_customer_id = e.entity_id', |
||
| 33 | ['ac_customer.activecampaign_id'] |
||
| 34 | ); |
||
| 35 | |||
| 36 | return $this; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param string $email |
||
| 41 | * @return Collection |
||
| 42 | */ |
||
| 43 | public function addEmailFilter(string $email): self |
||
| 44 | { |
||
| 45 | $this->getSelect()->where('e.email = ?', $email); |
||
| 46 | return $this; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return Collection |
||
| 51 | */ |
||
| 52 | public function addContactOmittedFilter(): self |
||
| 53 | { |
||
| 54 | $this->getSelect()->where('ac_contact.activecampaign_id IS NULL'); |
||
| 55 | return $this; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @return Collection |
||
| 60 | */ |
||
| 61 | public function addCustomerOmittedFilter(): self |
||
| 62 | { |
||
| 63 | $this->getSelect()->where('ac_customer.activecampaign_id IS NULL'); |
||
| 64 | return $this; |
||
| 65 | } |
||
| 66 | } |
||
| 67 |
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.