commerceleague /
magento2-module-activecampaign
| 1 | <?php |
||||
| 2 | declare(strict_types=1); |
||||
| 3 | /** |
||||
| 4 | */ |
||||
| 5 | |||||
| 6 | namespace CommerceLeague\ActiveCampaign\Cron; |
||||
| 7 | |||||
| 8 | use CommerceLeague\ActiveCampaign\Helper\Config as ConfigHelper; |
||||
| 9 | use CommerceLeague\ActiveCampaign\MessageQueue\Topics; |
||||
| 10 | use CommerceLeague\ActiveCampaign\Model\ResourceModel\Customer\Collection as CustomerCollection; |
||||
| 11 | use CommerceLeague\ActiveCampaign\Model\ResourceModel\Customer\CollectionFactory as CustomerCollectionFactory; |
||||
|
0 ignored issues
–
show
|
|||||
| 12 | use CommerceLeague\ActiveCampaign\Model\ResourceModel\Subscriber\Collection as SubscriberCollection; |
||||
| 13 | use CommerceLeague\ActiveCampaign\Model\ResourceModel\Subscriber\CollectionFactory as SubscriberCollectionFactory; |
||||
|
0 ignored issues
–
show
The type
CommerceLeague\ActiveCam...riber\CollectionFactory was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||||
| 14 | use Magento\Framework\MessageQueue\PublisherInterface; |
||||
| 15 | |||||
| 16 | /** |
||||
| 17 | * Class ExportOmittedContacts |
||||
| 18 | */ |
||||
| 19 | class ExportOmittedContacts implements CronInterface |
||||
| 20 | { |
||||
| 21 | /** |
||||
| 22 | * @var ConfigHelper |
||||
| 23 | */ |
||||
| 24 | private $configHelper; |
||||
| 25 | |||||
| 26 | /** |
||||
| 27 | * @var CustomerCollectionFactory |
||||
| 28 | */ |
||||
| 29 | private $customerCollectionFactory; |
||||
| 30 | |||||
| 31 | /** |
||||
| 32 | * @var SubscriberCollectionFactory |
||||
| 33 | */ |
||||
| 34 | private $subscriberCollectionFactory; |
||||
| 35 | |||||
| 36 | /** |
||||
| 37 | * @var PublisherInterface |
||||
| 38 | */ |
||||
| 39 | private $publisher; |
||||
| 40 | |||||
| 41 | /** |
||||
| 42 | * @param ConfigHelper $configHelper |
||||
| 43 | * @param CustomerCollectionFactory $customerCollectionFactory |
||||
| 44 | * @param SubscriberCollectionFactory $subscriberCollectionFactory |
||||
| 45 | * @param PublisherInterface $publisher |
||||
| 46 | */ |
||||
| 47 | public function __construct( |
||||
| 48 | ConfigHelper $configHelper, |
||||
| 49 | CustomerCollectionFactory $customerCollectionFactory, |
||||
| 50 | SubscriberCollectionFactory $subscriberCollectionFactory, |
||||
| 51 | PublisherInterface $publisher |
||||
| 52 | ) { |
||||
| 53 | $this->configHelper = $configHelper; |
||||
| 54 | $this->customerCollectionFactory = $customerCollectionFactory; |
||||
| 55 | $this->subscriberCollectionFactory = $subscriberCollectionFactory; |
||||
| 56 | $this->publisher = $publisher; |
||||
| 57 | } |
||||
| 58 | |||||
| 59 | /** |
||||
| 60 | * @inheritDoc |
||||
| 61 | */ |
||||
| 62 | public function run(): void |
||||
| 63 | { |
||||
| 64 | if (!$this->configHelper->isEnabled() || !$this->configHelper->isContactExportEnabled()) { |
||||
| 65 | return; |
||||
| 66 | } |
||||
| 67 | |||||
| 68 | $customerIds = $this->getCustomerIds(); |
||||
| 69 | |||||
| 70 | foreach ($customerIds as $customerId) { |
||||
| 71 | $this->publisher->publish( |
||||
| 72 | Topics::CUSTOMER_CONTACT_EXPORT, |
||||
| 73 | json_encode(['magento_customer_id' => $customerId]) |
||||
|
0 ignored issues
–
show
json_encode(array('magen...er_id' => $customerId)) of type string is incompatible with the type array|object expected by parameter $data of Magento\Framework\Messag...herInterface::publish().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 74 | ); |
||||
| 75 | } |
||||
| 76 | |||||
| 77 | $subscriberEmails = $this->getSubscriberEmails(); |
||||
| 78 | |||||
| 79 | foreach ($subscriberEmails as $subscriberEmail) { |
||||
| 80 | $this->publisher->publish( |
||||
| 81 | Topics::NEWSLETTER_CONTACT_EXPORT, |
||||
| 82 | json_encode(['email' => $subscriberEmail]) |
||||
| 83 | ); |
||||
| 84 | } |
||||
| 85 | } |
||||
| 86 | |||||
| 87 | /** |
||||
| 88 | * @return array |
||||
| 89 | */ |
||||
| 90 | private function getCustomerIds(): array |
||||
| 91 | { |
||||
| 92 | /** @var CustomerCollection $customerCollection */ |
||||
| 93 | $customerCollection = $this->customerCollectionFactory->create(); |
||||
| 94 | $customerCollection->addContactOmittedFilter(); |
||||
| 95 | |||||
| 96 | return $customerCollection->getAllIds(); |
||||
| 97 | } |
||||
| 98 | |||||
| 99 | /** |
||||
| 100 | * @return array |
||||
| 101 | */ |
||||
| 102 | private function getSubscriberEmails(): array |
||||
| 103 | { |
||||
| 104 | /** @var SubscriberCollection $subscriberCollection */ |
||||
| 105 | $subscriberCollection = $this->subscriberCollectionFactory->create(); |
||||
| 106 | $subscriberCollection->excludeCustomers(); |
||||
| 107 | $subscriberCollection->addContactOmittedFilter(); |
||||
| 108 | |||||
| 109 | return $subscriberCollection->getAllEmails(); |
||||
| 110 | } |
||||
| 111 | } |
||||
| 112 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths