@param mixed $oldParentId
@param mixed $newParentId

@return array
199946
protected function getCopiedLocationsMap($oldParentId, $newParentId)
    {
        $originalLocations = $this->locationGateway->getSubtreeContent($oldParentId);
        $copiedLocations = $this->locationGateway->getSubtreeContent($newParentId);

        $map = array();
        foreach ($originalLocations as $index => $originalLocation) {
            $map['eznode:' . $originalLocation['node_id']] = 'eznode:' . $copiedLocations[$index]['node_id'];
        }

        return $map;
    }
814490
private function getChildrenIds($categoryId)
    {
        $parentChildMapping = $this->getParentChildMapping();
        if ('' === $categoryId) {
            $categoryId = self::PARENT_CHILD_MAPPING_LOOKUP_FOR_ROOT_NODES;
        }
        if (!isset($parentChildMapping[$categoryId])) {
            return array();
        }

        return $parentChildMapping[$categoryId];
    }
695699
public static function existsInParentsChain($nodeId, $parentId)
    {
        $nextParentId = $parentId;
        $exists = false;
        while (true) {
            if ($nodeId == $nextParentId) {
                $exists = true;
                break;
            }

            $nextParentNode = static::node($nextParentId);
            if (empty($nextParentNode)) break;

            $nextParentId = $nextParentNode['parent_id'];
         }

         return $exists;
    }
699364
public static function nodesTreeList($parentId = 0, $level = 0, $shiftPrefix = '. ')
    {
        if (!isset(static::$_nodesTreeList[$parentId][$level][$shiftPrefix])) {
            $tree = [];
            $list = [];

            $parentNode = static::node($parentId);
            if (!empty($parentNode)) {
                $grandParentId = $parentNode['parent_id'];
                $grandParentNode = static::node($grandParentId);
                $nodePath = (empty($grandParentNode->nodePath)
                             ? '' : $grandParentNode->nodePath . '/'
                         ) . $parentNode['slug'];
                $list[$parentId] = str_repeat($shiftPrefix, $level) . $nodePath;
                $tree[$parentId] = str_repeat($shiftPrefix, $level) . $parentNode['slug'];
                static::saveNodePath($parentId, $nodePath);
            }

            $children = static::nodeChildren($parentId);
            foreach ($children as $child) {
                static::$_nodes[$child['id']] = $child;
                $list += static::nodesTreeList($child->id, $level+1, $shiftPrefix);
                $tree += static::nodesTree($child->id, $level+1, $shiftPrefix);
            }
            static::$_nodesTree[$parentId][$level][$shiftPrefix] = $tree;
            static::$_nodesTreeList[$parentId][$level][$shiftPrefix] = $list;
        }    
        return static::$_nodesTreeList[$parentId][$level][$shiftPrefix];
    }
1225356
public function getMoveEventChangeSet(Section $oldParent, $oldLeft, Section $newParent)
    {
        /* Create change set for move log event
         * If section's parent has changed, return old and new parent
         * Otherwise return old and new left to mark move up or down in the same parent
         */
        $newLeft = $this->getLeft();
        $changeSet = [
            'parentId' => [$oldParent->getId(), $newParent->getId()],
            'parentName' => [$oldParent->getActiveContribution()->getTitle(), $newParent->getActiveContribution()->getTitle()],
            'isParentRoot' => [$oldParent->isRoot(), $newParent->isRoot()],
            'left' => [$oldLeft, $newLeft],
        ];

        return $changeSet;
    }
1241004
protected function buildNestedArray(array $nodes = [], $parentId = 0)
    {
        $branch = [];

        if (empty($nodes)) {
            $nodes = $this->allNodes();
        }

        foreach ($nodes as $node) {
            if ($node[$this->parentColumn] === $parentId) {
                $children = $this->buildNestedArray($nodes, $node[$this->getKeyName()]);

                if ($children) {
                    $node['children'] = $children;
                }

                $branch[] = $node;
            }
        }

        return $branch;
    }
603474
public function buildChanges($oldEntity, $newEntity)
    {
        $changes = [];
        $entityDefinition = $this->definitions->getDefinition($oldEntity);
        foreach ($entityDefinition->getObservedProperties() as $property) {
            if ($this->isDifferent($property, $oldEntity, $newEntity)) {
                $oldValue = $this->propertyAccessor->getValue($oldEntity, $property->getName());
                $newValue = $this->propertyAccessor->getValue($newEntity, $property->getName());

                $changes[] = $this->buildChange($property, $oldValue, $newValue);
            }
        }

        return new ChangeSet($changes);
    }
902118
protected function copySubtree($actionMap, $oldParentAliasId, $newParentAliasId)
    {
        $rows = $this->gateway->loadAutogeneratedEntries($oldParentAliasId);
        $newIdsMap = array();
        foreach ($rows as $row) {
            $oldParentAliasId = $row['id'];

            // Ensure that same action entries remain grouped by the same id
            if (!isset($newIdsMap[$oldParentAliasId])) {
                $newIdsMap[$oldParentAliasId] = $this->gateway->getNextId();
            }

            $row['action'] = $actionMap[$row['action']];
            $row['parent'] = $newParentAliasId;
            $row['id'] = $row['link'] = $newIdsMap[$oldParentAliasId];
            $this->gateway->insertRow($row);

            $this->copySubtree(
                $actionMap,
                $oldParentAliasId,
                $row['id']
            );
        }
    }
1071189
public function getParentIds($rootId = 0)
    {
        if ($this->_parentIds === null) {
            // 增加对模型内置[[getAll()]]方法的支持，可避免多次查询数据库，优化性能
            if ($this->owner->hasMethod('getAll')) {
                $this->_parentIds = $this->getParentIdsInternal($rootId);
            } else {
                $this->_parentIds = Tree::getParentIds($this->owner, 0, $this->pkField, $this->parentField, $rootId);
            }
        }
        
        return $this->_parentIds;
    }
338958
public function getByParent( $parentId, $parentType, $config = [] ) {

		$modelClass	= static::$modelClass;

		return $modelClass::findByParent( $parentId, $parentType, $config );
	}
735071
public function newAction($parent_id) {
        $em = $this->getDoctrine()->getManager();

        $parent = $em->getRepository('AmulenClassificationBundle:Category')->findOneBy(array("id" => $parent_id));

        $entity = new Category();
        $entity->setParent($parent);

        $form = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
1061406
protected function getParentsHierarchyField($dataObject) {
		
		// see if we've got Parent values
		if (is_object($dataObject) && method_exists($dataObject, 'hasField') && $dataObject->hasField('ParentID')) {
			$parentsField = array('Type' => '', 'Value' => null);
			$parents = array();
			
			$parent = $dataObject;
			while ($parent && $parent->ParentID) {
				$parents[] = $parent->ParentID;
				$parent = $parent->Parent();
				// fix for odd behaviour - in some instance a node is being assigned as its own parent. 
				if ($parent->ParentID == $parent->ID) {
					$parent = null;
				}
			}
			$parentsField['Value'] = $parents;
			return $parentsField;
		}
	}
1233685
public function setParentId( $parentid )
	{
		if ( $parentid == $this->getParentId() ) { return; }

		$this->_values['parentid'] = (int) $parentid;
		$this->setModified();
	}
1294917
public function getParents($id)
    {
        $url = $this->buildUrlByMethodName(
            'getGetParentsUrl',
            ['id' => $id]
        );

        return $this
            ->buildLocations(
                $this->resolveApiUrl($url)
            );
    }
371401
public static function GetAncestors($CategoryID, $CheckPermissions = TRUE) {
      $Categories = self::Categories();
      $Result = array();
      
      // Grab the category by ID or url code.
      if (is_numeric($CategoryID)) {
         if (isset($Categories[$CategoryID]))
            $Category = $Categories[$CategoryID];
      } else {
         foreach ($Categories as $ID => $Value) {
            if ($Value['UrlCode'] == $CategoryID) {
               $Category = $Categories[$ID];
               break;
            }
         }
      }

      if (!isset($Category))
         return $Result;

      // Build up the ancestor array by tracing back through parents.
      $Result[$Category['CategoryID']] = $Category;
      $Max = 20;
      while (isset($Categories[$Category['ParentCategoryID']])) {
         // Check for an infinite loop.
         if ($Max <= 0)
            break;
         $Max--;
         
         if ($CheckPermissions && !$Category['PermsDiscussionsView']) {
            $Category = $Categories[$Category['ParentCategoryID']];
            continue;
         }
         
         if ($Category['CategoryID'] == -1)
            break;

         // Return by ID or code.
         if (is_numeric($CategoryID))
            $ID = $Category['CategoryID'];
         else
            $ID = $Category['UrlCode'];

         $Result[$ID] = $Category;

         $Category = $Categories[$Category['ParentCategoryID']];
      }
      $Result = array_reverse($Result, TRUE); // order for breadcrumbs
      return $Result;
   }
811552
public static function findByParent( $parentId, $parentType, $config = [] ) {

		return self::queryByParent( $parentId, $parentType, $config )->all();
	}
861649
public function getCountByParent( $parentId, $parentType ) {

		$modelClass	= static::$modelClass;

		return $modelClass::queryByParent( $parentId, $parentType )->count();
	}