-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved removing subscriber queue to separate class
- Loading branch information
1 parent
d98dc43
commit ec464f5
Showing
3 changed files
with
52 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
app/code/Magento/Newsletter/Model/RemoveSubscriberFromQueueLink.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Newsletter\Model; | ||
|
||
use Magento\Framework\App\ResourceConnection; | ||
use Magento\Framework\DB\Adapter\AdapterInterface; | ||
|
||
/** | ||
* Responsible for removing subscriber from queue | ||
*/ | ||
class RemoveSubscriberFromQueueLink | ||
{ | ||
/** | ||
* @var AdapterInterface | ||
*/ | ||
private $connection; | ||
|
||
/** | ||
* @param ResourceConnection $resource | ||
*/ | ||
public function __construct(ResourceConnection $resource) | ||
{ | ||
$this->connection = $resource->getConnection(); | ||
} | ||
|
||
/** | ||
* Removes subscriber from queue | ||
* | ||
* @param int $subscriberId | ||
* @return void | ||
*/ | ||
public function execute(int $subscriberId): void | ||
{ | ||
$this->connection->delete( | ||
$this->connection->getTableName('newsletter_queue_link'), | ||
['subscriber_id = ?' => $subscriberId, 'letter_sent_at IS NULL'] | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters