Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BulkCleanup.php
Go to the documentation of this file.
1 <?php
7 
13 
15 {
19  private $dateTime;
20 
24  private $metadataPool;
25 
29  private $resourceConnection;
30 
34  private $scopeConfig;
35 
39  private $date;
40 
49  public function __construct(
50  MetadataPool $metadataPool,
51  ResourceConnection $resourceConnection,
52  DateTime $dateTime,
53  ScopeConfigInterface $scopeConfig,
54  \Magento\Framework\Stdlib\DateTime\DateTime $time
55  ) {
56  $this->metadataPool = $metadataPool;
57  $this->resourceConnection = $resourceConnection;
58  $this->dateTime = $dateTime;
59  $this->scopeConfig = $scopeConfig;
60  $this->date = $time;
61  }
62 
68  public function execute()
69  {
70  $metadata = $this->metadataPool->getMetadata(BulkSummaryInterface::class);
71  $connection = $this->resourceConnection->getConnectionByName($metadata->getEntityConnectionName());
72 
73  $bulkLifetime = 3600 * 24 * (int)$this->scopeConfig->getValue('system/bulk/lifetime');
74  $maxBulkStartTime = $this->dateTime->formatDate($this->date->gmtTimestamp() - $bulkLifetime);
75  $connection->delete($metadata->getEntityTable(), ['start_time <= ?' => $maxBulkStartTime]);
76  }
77 }
__construct(MetadataPool $metadataPool, ResourceConnection $resourceConnection, DateTime $dateTime, ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\DateTime\DateTime $time)
Definition: BulkCleanup.php:49
$connection
Definition: bulk.php:13
$dateTime