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
32 {
37  protected $_value = null;
38 
43  protected $_children = array();
44 
49  protected $_parent = null;
50 
58  public function __construct($value, Zend_Server_Reflection_Node $parent = null)
59  {
60  $this->_value = $value;
61  if (null !== $parent) {
62  $this->setParent($parent, true);
63  }
64 
65  return $this;
66  }
67 
76  public function setParent(Zend_Server_Reflection_Node $node, $new = false)
77  {
78  $this->_parent = $node;
79 
80  if ($new) {
81  $node->attachChild($this);
82  return;
83  }
84  }
85 
93  public function createChild($value)
94  {
95  $child = new self($value, $this);
96 
97  return $child;
98  }
99 
107  {
108  $this->_children[] = $node;
109 
110  if ($node->getParent() !== $this) {
111  $node->setParent($this);
112  }
113  }
114 
120  public function getChildren()
121  {
122  return $this->_children;
123  }
124 
130  public function hasChildren()
131  {
132  return count($this->_children) > 0;
133  }
134 
140  public function getParent()
141  {
142  return $this->_parent;
143  }
144 
150  public function getValue()
151  {
152  return $this->_value;
153  }
154 
161  public function setValue($value)
162  {
163  $this->_value = $value;
164  }
165 
175  public function getEndPoints()
176  {
177  $endPoints = array();
178  if (!$this->hasChildren()) {
179  return $endPoints;
180  }
181 
182  foreach ($this->_children as $child) {
183  $value = $child->getValue();
184 
185  if (null === $value) {
186  $endPoints[] = $this;
187  } elseif ((null !== $value)
188  && $child->hasChildren())
189  {
190  $childEndPoints = $child->getEndPoints();
191  if (!empty($childEndPoints)) {
192  $endPoints = array_merge($endPoints, $childEndPoints);
193  }
194  } elseif ((null !== $value) && !$child->hasChildren()) {
195  $endPoints[] = $child;
196  }
197  }
198 
199  return $endPoints;
200  }
201 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
__construct($value, Zend_Server_Reflection_Node $parent=null)
Definition: Node.php:58
attachChild(Zend_Server_Reflection_Node $node)
Definition: Node.php:106
$value
Definition: gender.phtml:16
setParent(Zend_Server_Reflection_Node $node, $new=false)
Definition: Node.php:76