Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
GroupRegistry Class Reference

Public Member Functions

 __construct (GroupFactory $groupFactory)
 
 retrieve ($groupId)
 
 remove ($groupId)
 

Protected Attributes

 $registry = []
 
 $groupFactory
 

Detailed Description

Registry for Customer Group models

Definition at line 15 of file GroupRegistry.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( GroupFactory  $groupFactory)
Parameters
GroupFactory$groupFactory

Definition at line 30 of file GroupRegistry.php.

31  {
32  $this->groupFactory = $groupFactory;
33  }

Member Function Documentation

◆ remove()

remove (   $groupId)

Remove an instance of the Group Model from the registry

Parameters
int$groupId
Returns
void

Definition at line 62 of file GroupRegistry.php.

63  {
64  unset($this->registry[$groupId]);
65  }

◆ retrieve()

retrieve (   $groupId)

Get instance of the Group Model identified by an id

Parameters
int$groupId
Returns
Group
Exceptions
NoSuchEntityException

Definition at line 42 of file GroupRegistry.php.

43  {
44  if (isset($this->registry[$groupId])) {
45  return $this->registry[$groupId];
46  }
47  $group = $this->groupFactory->create();
48  $group->load($groupId);
49  if ($group->getId() === null || $group->getId() != $groupId) {
51  }
52  $this->registry[$groupId] = $group;
53  return $group;
54  }
$group
Definition: sections.phtml:16

Field Documentation

◆ $groupFactory

$groupFactory
protected

Definition at line 25 of file GroupRegistry.php.

◆ $registry

$registry = []
protected

Definition at line 20 of file GroupRegistry.php.


The documentation for this class was generated from the following file: