méthode récussive de construction du tableau des options de l'arbre menu

@param $node : noeud local traité
@param $nodesArray : tableau des noeuds - feuilles de l'arbre menu
@return array : tableau des noeuds - feuilles de l'arbre menu après traitement
320438
public function buildOptionsArray($node, $nodesArray)
    {
        $item           = [];
        $item['ref']    = $node['ref'];
        $item['label']  = $node['label'];
        $item['link']   = $node['link'];
        $item['target'] = $node['target'];
        $item['pos']    = $node['pos'];
        $item['parent'] = $node['parent'];

        $nodesArray[]   = $item;
        if (array_key_exists('children', $node)) {
            foreach ($node['children'] as $child) {
                $nodesArray = $this->buildOptionsArray($child, $nodesArray);
            }
        }
        return $nodesArray;
    }
503359
protected function getGrantedNodes(array $nodes)
    {
        /**
         * @var ReadNodeInterface $node
         */
        foreach ($nodes as $key => $node) {
            if (!$this->isGrantedNode($node)) {
                unset($nodes[$key]);
            }
        }

        return $nodes;
    }
718666
public function leaveNode(Node $node)
    {
        // Collect arguments as variables
        if ($node instanceof Expr\FuncCall
            || $node instanceof Expr\MethodCall
            || $node instanceof Expr\StaticCall
        ) {
            $variables = $this->getSplatCallVars($node->args);
            if (is_null($variables)) {
                return;
            }
        }

        // Call to call_user_func_array
        if ($node instanceof Expr\FuncCall) {
            $callee = new Scalar\String_($node->name);
            return $this->splatToCallUserFuncArray($callee, $variables);
        } elseif ($node instanceof Expr\MethodCall) {
            if ($node->var instanceof Expr\New_) {
                $var = $node->var;
            } elseif ($node->var instanceof Expr\Variable) {
                $var = new Expr\Variable($node->var->name);
            } else {
                return;
            }
            $callee = new Expr\Array_([$var,new Scalar\String_($node->name)]);
            return $this->splatToCallUserFuncArray($callee, $variables);
        } elseif ($node instanceof Expr\StaticCall) {
            $var = new Expr\ClassConstFetch($node->class, 'class');
            if ($this->useStringifiedStaticCalls) {
                $var = $this->classConstToStrVisitor->leaveNode($var);
            }
            $callee = new Expr\Array_([$var, new Scalar\String_($node->name)]);
            return $this->splatToCallUserFuncArray($callee, $variables);
        }
    }
129326
private function getNodeChildrenProperties(NodePath $nodePath, string $property) : array
    {
        $nodeData = $this->getNode($nodePath);
        $result = [];
        if (!empty($nodeData)) {
            if ($nodeData['nodeType'] == 'object') {
                foreach ($nodeData as $itemName => $value) {
                    if (is_array($value)) {
                        $itemName = $this->decodeNodeName($itemName);
                        // it is a child node
                        if (isset($value[$property])) {
                            $result[$itemName] = $value[$property];
                        } else {
                            $result[$itemName] = null;
                        }
                    }
                }
            } elseif ($nodeData['nodeType'] == 'scalar') {
                foreach ($nodeData as $itemName => $value) {
                    if ($itemName == $property) {
                        $result[$nodePath->getLast()] = $value;
                    }
                }
            }
        }
        return $result;
    }
642419
public function createPageNode(array $options = array())
    {
        $node = new MenuNode();
        $node->type = MenuNode::TYPE_PAGE;

        if (isset($options['label'])) {
            $node->label = $options['label'];
        }

        if (isset($options['translate_label'])) {
            $node->translateLabel = $options['translate_label'];
        }

        if (isset($options['icon'])) {
            $node->iconClass = $options['icon'];
        }

        if (isset($options['roles'])) {
            $node->roles = ArrayUtils::to_array($options['roles']);
        }

        if (isset($options['action'])) {
            $action = $options['action'];

            if (is_array($action)) {
                if (isset($action['target'])) {
                    $node->target = $action['target'];
                }

                if (isset($options['url'])) {
                    $node->url = $options['url'];
                }

                if (isset($action['route'])) {
                    $node->route = $action['route'];
                    $node->routeParams = (isset($action['params']) && is_array($action['params'])) ? $action['params'] : array();
                    $node->url = $this->container->get('router')->generate($node->route, $node->routeParams);
                }
            } else {
                $node->route = $action;
                $node->url = $this->container->get('router')->generate($node->route);
            }
        }

        return $node;
    }
957729
protected function wrapOptions(array $nodes)
	{
		$ret = array();

		foreach ( $nodes as $node_element ) {
			/** @var SelectOption $option */
			$option = SelectOption::fromNodeElement($node_element, $this->getPageFactory());
			$ret[] = $option->setSelect($this);
		}

		return $ret;
	}
769594
public function addToArrayNode(AbstractNode $node): QueryBuilderInterface
    {
        if (!$this->node instanceof ArrayNode) {
            throw new \Exception(sprintf('You cannot call %s on node type: %s', __FUNCTION__, get_class($this->node)));
        }

        $this->node->add($node);
        $this->reassignParent($node);

        return $this;
    }
989605
public static function getValueByNodes(array $data, array $nodes, $default = null)
    {
        $temp = $data;

        foreach ($nodes as $name) {
            if (isset($temp[$name])) {
                $temp = $temp[$name];
            } else {
                $temp = $default;
                break;
            }
        }

        return $temp;
    }
1169897
protected static function serializeVarsRec( $array, &$node )
	{
		foreach( $array as $key => $value)
		{
			switch( gettype( $value ) )
			{
				case 'NULL':
					$child	= new XML_DOM_Node( "null" );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'boolean':
					$child	= new XML_DOM_Node( "boolean", (int) $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'string':
					$child	= new XML_DOM_Node( "string", $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'integer':
					$child	= new XML_DOM_Node( "integer", $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'double':
					$child	= new XML_DOM_Node( "double", $value );
					$child->setAttribute( "name", $key );
					$node->addChild( $child );
					break;
				case 'array':
					$child	= new XML_DOM_Node( "array" );
					$child->setAttribute( "name", $key );
					self::serializeVarsRec( $value, $child );
					$node->addChild( $child );
					break;
				case 'object':
					$child	= new XML_DOM_Node( "object" );
					$child->setAttribute( "name", $key );
					$child->setAttribute( "class", get_class( $value ) );
					$vars	= get_object_vars( $value );
					self::serializeVarsRec( $vars, $child );
					$node->addChild( $child );
					break;
			}
		}
	}
795670
private function &getNodeReference(&$node, array $pointerArray)
    {
        foreach ($pointerArray as $singlePath) {
            $accessor = $this->getAccessorForNode($node, $pointerArray, $singlePath);
            $node = & $accessor->get($node, $singlePath);
        }

        return $node;
    }
1039533
private function &convert($nodeName, $arr = [])
    {
        /** @var \DOMDocument $xml */
        $xml = $this->xml;

        /** @var \DOMElement $node */
        $node = $xml->createElement($nodeName);

        if (is_array($arr)) {

            // get the attributes first.;
            if (isset($arr['@attributes'])) {

                $this->extractAttributes($node, $arr, $nodeName);

                unset($arr['@attributes']); //remove the key from the array once done.
            }

            // Check if it has a value stored in @value, if yes store the value and return
            // else check if its directly stored as string.
            if (isset($arr['@value'])) {

                $node->appendChild($xml->createTextNode($this->boolToString($arr['@value'])));
                unset($arr['@value']);    //remove the key from the array once done.

                //Return from recursion, as a note with value cannot have child nodes.
                return $node;

            } elseif (isset($arr['@cdata'])) {

                $node->appendChild($xml->createCDATASection($this->boolToString($arr['@cdata'])));
                unset($arr['@cdata']);    //remove the key from the array once done.

                //Return from recursion, as a note with cdata cannot have child nodes.
                return $node;
            }

            // recurse to get the node for that key
            foreach ($arr as $key => $value) {

                if (! $this->isValidTagName($key)) {

                    throw new \Exception(__CLASS__.' Illegal character in tag name. tag: '.$key.' in node: '.$nodeName);

                }

                if (is_array($value) && is_numeric(key($value))) {

                    // MORE THAN ONE NODE OF ITS KIND;
                    // if the new array is numeric index, means it is array of nodes of the same kind
                    // it should follow the parent key name
                    foreach ($value as $k => $v) {

                        $node->appendChild($this->convert($key, $v));

                    }

                } else {

                    // ONLY ONE NODE OF ITS KIND
                    $node->appendChild($this->convert($key, $value));

                }

                unset($arr[$key]); //remove the key from the array once done.
            }

        } else {

            $node->appendChild($xml->createTextNode($this->boolToString($arr)));

        }

        return $node;
    }
487170
public function getNodeCampMenu(NodeInterface $node) {
    if (!($camp = $this->getNodeCampNode($node))) {
      return [];
    }

    return $this->getCampNodeCampMenu($camp);
  }
682179
public function makeArrayOperator(AbstractArrayOperatorNode $node)
    {
        $nodeName = $node->getNodeName();

        if (!isset($this->literals['ArrayOperator'][$nodeName])) {
            throw new DataStoreException(
                'The Array Operator not supported: ' . $nodeName
            );
        }

        $arrayValues = $node->getValues();
        $strQuery = $this->literals['ArrayOperator'][$nodeName]['before']
            . $this->prepareFieldName($node->getField())
            . $this->literals['ArrayOperator'][$nodeName]['between'];

        foreach ($arrayValues as $value) {
            $strQuery = $strQuery
                . $this->prepareFieldValue($value)
                . $this->literals['ArrayOperator'][$nodeName]['delimiter'];
        }

        $strQuery = rtrim($strQuery, $this->literals['ArrayOperator'][$nodeName]['delimiter']);
        $strQuery = $strQuery . $this->literals['ArrayOperator'][$nodeName]['after'];

        return $strQuery;
    }
6643
public function getAllValuesNode(Node $node = null, $property) {
        $allValues = $this->getAllValues($node, $property);
        $output = [];
        foreach ($allValues as $a)
            if (is_a($a, 'ML\JsonLD\Node'))
                $output[] = $a;

        return $output;
    }
532553
protected function writeRecursive( &$node, $array )
	{
		foreach( $array as $key => $value )
		{
			if( is_array( $value ) )
			{
				$child	= new XML_DOM_Node( $this->getOption( 'tag_level' ) );
				$child->setAttribute( 'name', $key );
				$this->writeRecursive( $child, $array[$key] );
				$node->addChild( $child );
			}
			else
			{
				$child	= new XML_DOM_Node( $this->getOption( 'tag_pair' ) );
				$child->setAttribute( 'name', $key );
				$child->setAttribute( 'type', gettype( $value ) );
				$child->setContent( utf8_encode( $value ) );
				$node->addChild( $child );
			}
		}
	}
1077722
public static function getChildElements($node)
    {
        $ret = array();
        $nodes = $node->childNodes;
        foreach ($nodes as $node) {
            if ($node instanceof DOMElement) {
                array_push($ret, $node);
            }
        }
        return $ret;
    }
872138
public function getPropertiesArray(NodeInterface $node)
    {
        $properties = [];
        foreach ($node->getNodeType()->getProperties() as $propertyName => $propertyConfiguration) {
            if ($propertyName[0] === '_' && $propertyName[1] === '_') {
                // skip fully-private properties
                continue;
            }

            $properties[$propertyName] = $this->getProperty($node, $propertyName);
        }

        return $properties;
    }