AuthorizationFactory.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Authorization\Setup;
  7. /**
  8. * Resource Setup Model
  9. *
  10. * @codeCoverageIgnore
  11. */
  12. class AuthorizationFactory
  13. {
  14. /**
  15. * Role model factory
  16. *
  17. * @var \Magento\Authorization\Model\RoleFactory
  18. */
  19. protected $_roleCollectionFactory;
  20. /**
  21. * Factory for rules model
  22. *
  23. * @var \Magento\Authorization\Model\RulesFactory
  24. */
  25. protected $_rulesCollectionFactory;
  26. /**
  27. * Role model factory
  28. *
  29. * @var \Magento\Authorization\Model\RoleFactory
  30. */
  31. protected $_roleFactory;
  32. /**
  33. * Rules model factory
  34. *
  35. * @var \Magento\Authorization\Model\RulesFactory
  36. */
  37. protected $_rulesFactory;
  38. /**
  39. * Init
  40. *
  41. * @param \Magento\Authorization\Model\ResourceModel\Role\CollectionFactory $roleCollectionFactory
  42. * @param \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory $rulesCollectionFactory
  43. * @param \Magento\Authorization\Model\RoleFactory $roleFactory
  44. * @param \Magento\Authorization\Model\RulesFactory $rulesFactory
  45. */
  46. public function __construct(
  47. \Magento\Authorization\Model\ResourceModel\Role\CollectionFactory $roleCollectionFactory,
  48. \Magento\Authorization\Model\ResourceModel\Rules\CollectionFactory $rulesCollectionFactory,
  49. \Magento\Authorization\Model\RoleFactory $roleFactory,
  50. \Magento\Authorization\Model\RulesFactory $rulesFactory
  51. ) {
  52. $this->_roleCollectionFactory = $roleCollectionFactory;
  53. $this->_rulesCollectionFactory = $rulesCollectionFactory;
  54. $this->_roleFactory = $roleFactory;
  55. $this->_rulesFactory = $rulesFactory;
  56. }
  57. /**
  58. * Creates role collection
  59. *
  60. * @return \Magento\Authorization\Model\ResourceModel\Role\Collection
  61. */
  62. public function createRoleCollection()
  63. {
  64. return $this->_roleCollectionFactory->create();
  65. }
  66. /**
  67. * Creates rules collection
  68. *
  69. * @return \Magento\Authorization\Model\ResourceModel\Rules\Collection
  70. */
  71. public function createRulesCollection()
  72. {
  73. return $this->_rulesCollectionFactory->create();
  74. }
  75. /**
  76. * Creates role model
  77. *
  78. * @return \Magento\Authorization\Model\Role
  79. */
  80. public function createRole()
  81. {
  82. return $this->_roleFactory->create();
  83. }
  84. /**
  85. * Creates rules model
  86. *
  87. * @return \Magento\Authorization\Model\Rules
  88. */
  89. public function createRules()
  90. {
  91. return $this->_rulesFactory->create();
  92. }
  93. }