@@ -34,17 +34,24 @@ final class EnumeratedNode implements \JsonSerializable
3434 */
3535 protected $ arguments ;
3636
37- private function __construct (string $ contextPath , string $ nodeIdentifier , array $ arguments )
37+ /**
38+ * The node type name
39+ *
40+ * @var string
41+ */
42+ protected $ nodeTypeName ;
43+
44+ private function __construct (string $ contextPath , string $ nodeIdentifier , string $ nodeTypeName , array $ arguments )
3845 {
3946 $ this ->contextPath = $ contextPath ;
4047 $ this ->nodeIdentifier = $ nodeIdentifier ;
48+ $ this ->nodeTypeName = $ nodeTypeName ;
4149 $ this ->arguments = $ arguments ;
4250 }
4351
44-
45- static public function fromNode (NodeInterface $ node ): self
52+ static public function fromNode (NodeInterface $ node , array $ arguments = []): self
4653 {
47- return new self ($ node ->getContextPath (), $ node ->getIdentifier (), [] );
54+ return new self ($ node ->getContextPath (), $ node ->getIdentifier (), $ node -> getNodeType ()-> getName (), $ arguments );
4855 }
4956
5057 static public function fromJsonString (string $ enumeratedNodeString ): self
@@ -53,14 +60,15 @@ static public function fromJsonString(string $enumeratedNodeString): self
5360 if (!is_array ($ tmp )) {
5461 throw new \Exception ('EnumeratedNode cannot be constructed from: ' . $ enumeratedNodeString );
5562 }
56- return new self ($ tmp ['contextPath ' ], $ tmp ['nodeIdentifier ' ], $ tmp ['arguments ' ]);
63+ return new self ($ tmp ['contextPath ' ], $ tmp ['nodeIdentifier ' ], $ tmp ['nodeTypeName ' ] ?? '' , $ tmp [ ' arguments ' ]);
5764 }
5865
5966 public function jsonSerialize ()
6067 {
6168 return [
6269 'contextPath ' => $ this ->contextPath ,
6370 'nodeIdentifier ' => $ this ->nodeIdentifier ,
71+ 'nodeTypeName ' => $ this ->nodeTypeName ,
6472 'arguments ' => $ this ->arguments
6573 ];
6674 }
@@ -80,21 +88,23 @@ public function getDimensionsFromContextPath(): array
8088 return $ nodePathAndContext ['dimensions ' ];
8189 }
8290
83- /**
84- * @return string
85- */
8691 public function getNodeIdentifier (): string
8792 {
8893 return $ this ->nodeIdentifier ;
8994 }
9095
96+ public function getNodeTypeName (): string
97+ {
98+ return $ this ->nodeTypeName ;
99+ }
100+
91101 public function getArguments (): array
92102 {
93103 return $ this ->arguments ;
94104 }
95105
96106 public function debugString (): string
97107 {
98- return sprintf ('Node %s (%s) ' , $ this ->nodeIdentifier , $ this ->contextPath );
108+ return sprintf ('%s %s %s (%s) ' , $ this ->nodeTypeName , $ this -> nodeIdentifier , $ this -> arguments ? http_build_query ( $ this -> arguments ) . ' ' : '' , $ this ->contextPath );
99109 }
100- }
110+ }
0 commit comments