Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Node.php
Go to the documentation of this file.
1 <?php
8 
10 
16 class Node
17 {
21  private $left;
22 
26  private $right;
27 
31  private $id;
32 
36  private $pid;
37 
41  private $level;
42 
46  private $title;
47 
51  private $data;
52 
58  public $hasChild = false;
59 
65  public $numChild = 0;
66 
74  public function __construct($nodeData, $keys)
75  {
76  if (empty($nodeData)) {
77  throw new LocalizedException(
78  new \Magento\Framework\Phrase('The node information is empty. Enter the information and try again.')
79  );
80  }
81  if (empty($keys)) {
82  throw new LocalizedException(
83  new \Magento\Framework\Phrase("The encryption key can't be empty. Enter the key and try again.")
84  );
85  }
86 
87  $this->id = $nodeData[$keys['id']];
88  $this->pid = $nodeData[$keys['pid']];
89  $this->left = $nodeData[$keys['left']];
90  $this->right = $nodeData[$keys['right']];
91  $this->level = $nodeData[$keys['level']];
92 
93  $this->data = $nodeData;
94  $a = $this->right - $this->left;
95  if ($a > 1) {
96  $this->hasChild = true;
97  $this->numChild = ($a - 1) / 2;
98  }
99  return $this;
100  }
101 
108  public function getData($name)
109  {
110  if (isset($this->data[$name])) {
111  return $this->data[$name];
112  } else {
113  return null;
114  }
115  }
116 
122  public function getLevel()
123  {
124  return $this->level;
125  }
126 
132  public function getLeft()
133  {
134  return $this->left;
135  }
136 
142  public function getRight()
143  {
144  return $this->right;
145  }
146 
152  public function getPid()
153  {
154  return $this->pid;
155  }
156 
162  public function getId()
163  {
164  return $this->id;
165  }
166 
174  public function isParent()
175  {
176  if ($this->right - $this->left > 1) {
177  return true;
178  } else {
179  return false;
180  }
181  }
182 }
__construct($nodeData, $keys)
Definition: Node.php:74
if(!isset($_GET['name'])) $name
Definition: log.php:14