* @author Timo Hund */ class Node extends AbstractOptionFacetItem { /** * @var NodeCollection */ protected $childNodes; /** * @var Node */ protected $parentNode; /** * @var integer */ protected $depth; /** * @var string */ protected $key; /** * @param HierarchyFacet $facet * @param Node $parentNode * @param string $key * @param string $label * @param string $value * @param int $documentCount * @param bool $selected */ public function __construct(HierarchyFacet $facet, $parentNode = null, $key = '', $label = '', $value = '', $documentCount = 0, $selected = false) { parent::__construct($facet, $label, $value, $documentCount, $selected); $this->value = $value; $this->childNodes = new NodeCollection(); $this->parentNode = $parentNode; $this->key = $key; } /** * @return string */ public function getKey() { return $this->key; } /** * @param Node $node */ public function addChildNode(Node $node) { $this->childNodes->add($node); } /** * @return NodeCollection */ public function getChildNodes() { return $this->childNodes; } /** * @return Node|null */ public function getParentNode() { return $this->parentNode; } /** * @return bool */ public function getHasParentNode() { return $this->parentNode !== null; } /** * @return bool */ public function getHasChildNodeSelected() { /** @var Node $childNode */ foreach ($this->childNodes as $childNode) { if ($childNode->getSelected()) { return true; } } return false; } }