Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-store
Model
GroupRepository.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Store\Model
;
7
8
use
Magento\Framework\App\ObjectManager
;
9
use
Magento\Framework\Exception\NoSuchEntityException
;
10
use
Magento\Framework\App\Config
;
11
17
class
GroupRepository
implements
\Magento\Store\Api\GroupRepositoryInterface
18
{
22
protected
$groupFactory
;
23
27
protected
$entities
= [];
28
32
protected
$allLoaded
=
false
;
33
37
protected
$groupCollectionFactory
;
38
42
private
$appConfig;
43
48
public
function
__construct
(
49
GroupFactory
$groupFactory
,
50
\
Magento
\
Store
\Model\
ResourceModel
\
Group
\CollectionFactory
$groupCollectionFactory
51
) {
52
$this->groupFactory =
$groupFactory
;
53
$this->groupCollectionFactory =
$groupCollectionFactory
;
54
}
55
59
public
function
get
(
$id
)
60
{
61
if
(isset($this->entities[
$id
])) {
62
return
$this->entities[
$id
];
63
}
64
65
$group
= $this->groupFactory->create([
66
'data'
=> $this->getAppConfig()->
get
(
'scopes'
,
"groups/$id"
, [])
67
]);
68
69
if
(
null
===
$group
->getId()) {
70
throw
new
NoSuchEntityException
();
71
}
72
$this->entities[
$id
] =
$group
;
73
return
$group
;
74
}
75
79
public
function
getList
()
80
{
81
if
(!$this->allLoaded) {
82
$groups = $this->getAppConfig()->get(
'scopes'
,
'groups'
, []);
83
foreach
($groups as
$data
) {
84
$group
= $this->groupFactory->create([
85
'data'
=>
$data
86
]);
87
$this->entities[
$group
->getId()] =
$group
;
88
}
89
$this->allLoaded =
true
;
90
}
91
92
return
$this->entities
;
93
}
94
98
public
function
clean
()
99
{
100
$this->entities = [];
101
$this->allLoaded =
false
;
102
}
103
110
private
function
getAppConfig()
111
{
112
if
(!$this->appConfig) {
113
$this->appConfig =
ObjectManager::getInstance
()->get(Config::class);
114
}
115
return
$this->appConfig;
116
}
117
}
Magento\Framework\App\Config
Definition:
Base.php:9
Magento\Framework\App\ObjectManager\getInstance
static getInstance()
Definition:
ObjectManager.php:33
Magento\Catalog\Model\ResourceModel\Product
Definition:
CollectionTest.php:6
Magento\Store\Model\GroupRepository
Definition:
GroupRepository.php:17
$id
$id
Definition:
fieldset.phtml:14
Magento\Store\Model\GroupRepository\$groupCollectionFactory
$groupCollectionFactory
Definition:
GroupRepository.php:37
$group
$group
Definition:
sections.phtml:16
Magento\Framework\App\ObjectManager
Definition:
ConfigCache.php:8
Magento\Store\Model
$data
$data
Definition:
attribute_set_with_image_attribute.php:16
Magento\Store\Api\GroupRepositoryInterface
Definition:
GroupRepositoryInterface.php:16
Magento\Store\Model\GroupRepository\$entities
$entities
Definition:
GroupRepository.php:27
Magento\Store\Model\GroupRepository\__construct
__construct(GroupFactory $groupFactory, \Magento\Store\Model\ResourceModel\Group\CollectionFactory $groupCollectionFactory)
Definition:
GroupRepository.php:48
Magento\Store\Model\GroupRepository\getList
getList()
Definition:
GroupRepository.php:79
Magento
Magento\Store\Model\GroupRepository\$allLoaded
$allLoaded
Definition:
GroupRepository.php:32
Magento\Store\Model\Group
Definition:
Group.php:19
Magento\Store\Model\Store
Definition:
Store.php:38
Magento\Store\Model\GroupRepository\$groupFactory
$groupFactory
Definition:
GroupRepository.php:22
Magento\Store\Model\GroupRepository\clean
clean()
Definition:
GroupRepository.php:98
Magento\Framework\Exception\NoSuchEntityException
Definition:
NoSuchEntityException.php:16