Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Registry.php
Go to the documentation of this file.
1 <?php
7 
12 {
21  public function addParent($role, $parents)
22  {
23  try {
24  if ($role instanceof \Zend_Acl_Role_Interface) {
25  $roleId = $role->getRoleId();
26  } else {
27  $roleId = $role;
28  $role = $this->get($role);
29  }
30  } catch (\Zend_Acl_Role_Registry_Exception $e) {
31  throw new \Zend_Acl_Role_Registry_Exception("Child Role id '{$roleId}' does not exist");
32  }
33 
34  if (!is_array($parents)) {
35  $parents = [$parents];
36  }
37  foreach ($parents as $parent) {
38  try {
39  if ($parent instanceof \Zend_Acl_Role_Interface) {
40  $roleParentId = $parent->getRoleId();
41  } else {
42  $roleParentId = $parent;
43  }
44  $roleParent = $this->get($roleParentId);
45  } catch (\Zend_Acl_Role_Registry_Exception $e) {
46  throw new \Zend_Acl_Role_Registry_Exception("Parent Role id '{$roleParentId}' does not exist");
47  }
48  $this->_roles[$roleId]['parents'][$roleParentId] = $roleParent;
49  $this->_roles[$roleParentId]['children'][$roleId] = $role;
50  }
51  return $this;
52  }
53 }
$roleId
Definition: webapi_user.php:22