Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
BulkCleanup Class Reference

Public Member Functions

 __construct (MetadataPool $metadataPool, ResourceConnection $resourceConnection, DateTime $dateTime, ScopeConfigInterface $scopeConfig, \Magento\Framework\Stdlib\DateTime\DateTime $time)
 
 execute ()
 

Detailed Description

Definition at line 14 of file BulkCleanup.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( MetadataPool  $metadataPool,
ResourceConnection  $resourceConnection,
DateTime  $dateTime,
ScopeConfigInterface  $scopeConfig,
\Magento\Framework\Stdlib\DateTime\DateTime  $time 
)

BulkCleanup constructor.

Parameters
MetadataPool$metadataPool
ResourceConnection$resourceConnection
DateTime$dateTime
ScopeConfigInterface$scopeConfig
DateTime\DateTime$time

Definition at line 49 of file BulkCleanup.php.

55  {
56  $this->metadataPool = $metadataPool;
57  $this->resourceConnection = $resourceConnection;
58  $this->dateTime = $dateTime;
59  $this->scopeConfig = $scopeConfig;
60  $this->date = $time;
61  }

Member Function Documentation

◆ execute()

execute ( )

Remove all expired bulks and corresponding operations

Returns
void

Definition at line 68 of file BulkCleanup.php.

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  }
$connection
Definition: bulk.php:13

The documentation for this class was generated from the following file: