Collection.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Config\Model\ResourceModel\Config\Data;
  7. /**
  8. * Config data collection
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. * @api
  12. * @since 100.0.2
  13. */
  14. class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
  15. {
  16. /**
  17. * Define resource model
  18. *
  19. * @return void
  20. */
  21. protected function _construct()
  22. {
  23. $this->_init(
  24. \Magento\Framework\App\Config\Value::class,
  25. \Magento\Config\Model\ResourceModel\Config\Data::class
  26. );
  27. }
  28. /**
  29. * Add scope filter to collection
  30. *
  31. * @param string $scope
  32. * @param int $scopeId
  33. * @param string $section
  34. * @return $this
  35. */
  36. public function addScopeFilter($scope, $scopeId, $section)
  37. {
  38. $this->addFieldToFilter('scope', $scope);
  39. $this->addFieldToFilter('scope_id', $scopeId);
  40. $this->addFieldToFilter('path', ['like' => $section . '/%']);
  41. return $this;
  42. }
  43. /**
  44. * Add path filter
  45. *
  46. * @param string $section
  47. * @return $this
  48. */
  49. public function addPathFilter($section)
  50. {
  51. $this->addFieldToFilter('path', ['like' => $section . '/%']);
  52. return $this;
  53. }
  54. /**
  55. * Add value filter
  56. *
  57. * @param int|string $value
  58. * @return $this
  59. */
  60. public function addValueFilter($value)
  61. {
  62. $this->addFieldToFilter('value', ['like' => $value]);
  63. return $this;
  64. }
  65. }