Collection.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License").
  6. * You may not use this file except in compliance with the License.
  7. * A copy of the License is located at
  8. *
  9. * http://aws.amazon.com/apache2.0
  10. *
  11. * or in the "license" file accompanying this file. This file is distributed
  12. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied. See the License for the specific language governing
  14. * permissions and limitations under the License.
  15. */
  16. namespace Amazon\Payment\Model\ResourceModel\PendingAuthorization;
  17. use Amazon\Payment\Api\Data\PendingAuthorizationInterface;
  18. use Generator;
  19. use Magento\Framework\Api\SearchResultsInterface;
  20. use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
  21. use Amazon\Payment\Model\PendingAuthorization as PendingAuthorizationModel;
  22. use Amazon\Payment\Model\ResourceModel\PendingAuthorization as PendingAuthorizationResourceModel;
  23. class Collection extends AbstractCollection
  24. {
  25. protected function _construct()
  26. {
  27. $this->_init(PendingAuthorizationModel::class, PendingAuthorizationResourceModel::class);
  28. }
  29. /**
  30. * Get ID generator
  31. *
  32. * @return Generator
  33. */
  34. public function getIdGenerator()
  35. {
  36. $this->_renderFilters()->_renderOrders()->_renderLimit();
  37. $select = $this->getSelect();
  38. $statement = $select->getConnection()->query($select, $this->_bindParams);
  39. while ($row = $statement->fetch()) {
  40. yield $row[PendingAuthorizationInterface::ID];
  41. }
  42. }
  43. }