Node.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\DB\Tree;
  7. use Magento\Framework\Exception\LocalizedException;
  8. /**
  9. * @SuppressWarnings(PHPMD.UnusedPrivateField)
  10. *
  11. * @deprecated 102.0.0 Not used anymore.
  12. */
  13. class Node
  14. {
  15. /**
  16. * @var int
  17. */
  18. private $left;
  19. /**
  20. * @var int
  21. */
  22. private $right;
  23. /**
  24. * @var string|int
  25. */
  26. private $id;
  27. /**
  28. * @var string|int
  29. */
  30. private $pid;
  31. /**
  32. * @var int
  33. */
  34. private $level;
  35. /**
  36. * @var string
  37. */
  38. private $title;
  39. /**
  40. * @var array
  41. */
  42. private $data;
  43. /**
  44. * @var bool
  45. *
  46. * @deprecated 102.0.0
  47. */
  48. public $hasChild = false;
  49. /**
  50. * @var float|int
  51. *
  52. * @deprecated 102.0.0
  53. */
  54. public $numChild = 0;
  55. /**
  56. * @param array $nodeData
  57. * @param array $keys
  58. * @throws LocalizedException
  59. *
  60. * @deprecated 102.0.0
  61. */
  62. public function __construct($nodeData, $keys)
  63. {
  64. if (empty($nodeData)) {
  65. throw new LocalizedException(
  66. new \Magento\Framework\Phrase('The node information is empty. Enter the information and try again.')
  67. );
  68. }
  69. if (empty($keys)) {
  70. throw new LocalizedException(
  71. new \Magento\Framework\Phrase("The encryption key can't be empty. Enter the key and try again.")
  72. );
  73. }
  74. $this->id = $nodeData[$keys['id']];
  75. $this->pid = $nodeData[$keys['pid']];
  76. $this->left = $nodeData[$keys['left']];
  77. $this->right = $nodeData[$keys['right']];
  78. $this->level = $nodeData[$keys['level']];
  79. $this->data = $nodeData;
  80. $a = $this->right - $this->left;
  81. if ($a > 1) {
  82. $this->hasChild = true;
  83. $this->numChild = ($a - 1) / 2;
  84. }
  85. return $this;
  86. }
  87. /**
  88. * @param string $name
  89. * @return null|array
  90. *
  91. * @deprecated 102.0.0
  92. */
  93. public function getData($name)
  94. {
  95. if (isset($this->data[$name])) {
  96. return $this->data[$name];
  97. } else {
  98. return null;
  99. }
  100. }
  101. /**
  102. * @return int
  103. *
  104. * @deprecated 102.0.0
  105. */
  106. public function getLevel()
  107. {
  108. return $this->level;
  109. }
  110. /**
  111. * @return int
  112. *
  113. * @deprecated 102.0.0
  114. */
  115. public function getLeft()
  116. {
  117. return $this->left;
  118. }
  119. /**
  120. * @return int
  121. *
  122. * @deprecated 102.0.0
  123. */
  124. public function getRight()
  125. {
  126. return $this->right;
  127. }
  128. /**
  129. * @return string|int
  130. *
  131. * @deprecated 102.0.0
  132. */
  133. public function getPid()
  134. {
  135. return $this->pid;
  136. }
  137. /**
  138. * @return string|int
  139. *
  140. * @deprecated 102.0.0
  141. */
  142. public function getId()
  143. {
  144. return $this->id;
  145. }
  146. /**
  147. * Return true if node has child
  148. *
  149. * @return bool
  150. *
  151. * @deprecated 102.0.0
  152. */
  153. public function isParent()
  154. {
  155. if ($this->right - $this->left > 1) {
  156. return true;
  157. } else {
  158. return false;
  159. }
  160. }
  161. }