LogEntry.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * @copyright Vertex. All rights reserved. https://www.vertexinc.com/
  4. * @author Mediotype https://www.mediotype.com/
  5. */
  6. namespace Vertex\Tax\Model\ResourceModel;
  7. use Magento\Framework\Exception\CouldNotDeleteException;
  8. use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
  9. /**
  10. * Performs Datastore-related actions for the LogEntry repository
  11. */
  12. class LogEntry extends AbstractDb
  13. {
  14. /**
  15. * @inheritdoc
  16. *
  17. * MEQP2 Warning: Protected method. Needed to override AbstractDb's _construct
  18. */
  19. protected function _construct()
  20. {
  21. $this->_init('vertex_taxrequest', 'request_id');
  22. }
  23. /**
  24. * Delete records in a table based on the collection passed in
  25. *
  26. * @param LogEntry\Collection $collection
  27. * @throws CouldNotDeleteException
  28. */
  29. public function deleteByCollection($collection)
  30. {
  31. $query = $collection->getSelect()->deleteFromSelect('main_table');
  32. try {
  33. $this->getConnection()->query($query);
  34. } catch (\Exception $e) {
  35. throw new CouldNotDeleteException(__('%1 could not delete log entries', __CLASS__), $e);
  36. }
  37. }
  38. }