File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1006,6 +1006,19 @@ public function isDescendantOf(self $other)
1006
1006
$ this ->getLft () < $ other ->getRgt ();
1007
1007
}
1008
1008
1009
+ /**
1010
+ * Get whether a node is itself or a descendant of other node.
1011
+ *
1012
+ * @param self $other
1013
+ *
1014
+ * @return bool
1015
+ */
1016
+ public function isSelfOrDescendantOf (self $ other )
1017
+ {
1018
+ return $ this ->getLft () >= $ other ->getLft () &&
1019
+ $ this ->getLft () < $ other ->getRgt ();
1020
+ }
1021
+
1009
1022
/**
1010
1023
* Get whether the node is immediate children of other node.
1011
1024
*
@@ -1042,6 +1055,18 @@ public function isAncestorOf(self $other)
1042
1055
return $ other ->isDescendantOf ($ this );
1043
1056
}
1044
1057
1058
+ /**
1059
+ * Get whether the node is itself or an ancestor of other node, including immediate parent.
1060
+ *
1061
+ * @param self $other
1062
+ *
1063
+ * @return bool
1064
+ */
1065
+ public function isSelfOrAncestorOf (self $ other )
1066
+ {
1067
+ return $ other ->isSelfOrDescendantOf ($ this );
1068
+ }
1069
+
1045
1070
/**
1046
1071
* Get whether the node has moved since last save.
1047
1072
*
You can’t perform that action at this time.
0 commit comments