123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Framework\Data;
- use Magento\Framework\Data\Tree\Node;
- use Magento\Framework\Data\Tree\Node\Collection as NodeCollection;
- /**
- * Data tree
- *
- * @api
- * @author Magento Core Team <core@magentocommerce.com>
- * @since 100.0.2
- */
- class Tree
- {
- /**
- * Nodes collection
- *
- * @var NodeCollection
- */
- protected $_nodes;
- /**
- * Enter description here...
- *
- */
- public function __construct()
- {
- $this->_nodes = new NodeCollection($this);
- }
- /**
- * Enter description here...
- *
- * @return \Magento\Framework\Data\Tree
- */
- public function getTree()
- {
- return $this;
- }
- /**
- * Enter description here...
- *
- * @param Node $parentNode
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function load($parentNode = null)
- {
- }
- /**
- * Enter description here...
- *
- * @param int|string $nodeId
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function loadNode($nodeId)
- {
- }
- /**
- * Append child
- *
- * @param array|Node $data
- * @param Node $parentNode
- * @param Node $prevNode
- * @return Node
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function appendChild($data, $parentNode, $prevNode = null)
- {
- if (is_array($data)) {
- $node = $this->addNode(new Node($data, $parentNode->getIdField(), $this), $parentNode);
- } elseif ($data instanceof Node) {
- $node = $this->addNode($data, $parentNode);
- }
- return $node;
- }
- /**
- * Add node
- *
- * @param Node $node
- * @param Node $parent
- * @return Node
- */
- public function addNode($node, $parent = null)
- {
- $this->_nodes->add($node);
- $node->setParent($parent);
- if ($parent !== null && $parent instanceof Node) {
- $parent->addChild($node);
- }
- return $node;
- }
- /**
- * Move node
- *
- * @param Node $node
- * @param Node $parentNode
- * @param Node $prevNode
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function moveNodeTo($node, $parentNode, $prevNode = null)
- {
- }
- /**
- * Copy node
- *
- * @param Node $node
- * @param Node $parentNode
- * @param Node $prevNode
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function copyNodeTo($node, $parentNode, $prevNode = null)
- {
- }
- /**
- * Remove node
- *
- * @param Node $node
- * @return $this
- */
- public function removeNode($node)
- {
- $this->_nodes->delete($node);
- if ($node->getParent()) {
- $node->getParent()->removeChild($node);
- }
- unset($node);
- return $this;
- }
- /**
- * Create node
- *
- * @param Node $parentNode
- * @param Node $prevNode
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function createNode($parentNode, $prevNode = null)
- {
- }
- /**
- * Get child
- *
- * @param Node $node
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function getChild($node)
- {
- }
- /**
- * Get children
- *
- * @param Node $node
- * @return void
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function getChildren($node)
- {
- }
- /**
- * Enter description here...
- *
- * @return NodeCollection
- */
- public function getNodes()
- {
- return $this->_nodes;
- }
- /**
- * Enter description here...
- *
- * @param Node $nodeId
- * @return Node
- */
- public function getNodeById($nodeId)
- {
- return $this->_nodes->searchById($nodeId);
- }
- /**
- * Get path
- *
- * @param Node $node
- * @return array
- */
- public function getPath($node)
- {
- if ($node instanceof Node) {
- } elseif (is_numeric($node)) {
- if ($_node = $this->getNodeById($node)) {
- return $_node->getPath();
- }
- }
- return [];
- }
- }
|