Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Collection.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $entitySnapshot;
17 
27  public function __construct(
28  \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
29  \Psr\Log\LoggerInterface $logger,
30  \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
31  \Magento\Framework\Event\ManagerInterface $eventManager,
33  \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
34  \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
35  ) {
36  $this->entitySnapshot = $entitySnapshot;
37  parent::__construct(
38  $entityFactory,
39  $logger,
40  $fetchStrategy,
41  $eventManager,
43  $resource
44  );
45  }
46 
50  public function fetchItem()
51  {
52  $item = parent::fetchItem();
53  if ($item) {
54  $this->entitySnapshot->registerSnapshot($item);
55  }
56  return $item;
57  }
58 
62  protected function beforeAddLoadedItem(\Magento\Framework\DataObject $item)
63  {
64  $this->entitySnapshot->registerSnapshot($item);
65  return $item;
66  }
67 }
$resource
Definition: bulk.php:12
$logger
$connection
Definition: bulk.php:13
__construct(\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, Snapshot $entitySnapshot, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource=null)
Definition: Collection.php:27