@@ -29,6 +29,10 @@ class NestedSetsBehavior extends Behavior
29
29
const OPERATION_INSERT_AFTER = 'insertAfter ' ;
30
30
const OPERATION_DELETE_WITH_CHILDREN = 'deleteWithChildren ' ;
31
31
32
+ /**
33
+ * @var string|false
34
+ */
35
+ public $ treeAttribute = false ;
32
36
/**
33
37
* @var string
34
38
*/
@@ -37,10 +41,6 @@ class NestedSetsBehavior extends Behavior
37
41
* @var string
38
42
*/
39
43
public $ rightAttribute = 'rgt ' ;
40
- /**
41
- * @var string|false
42
- */
43
- public $ treeAttribute = false ;
44
44
/**
45
45
* @var string
46
46
*/
@@ -305,12 +305,11 @@ public function isRoot()
305
305
*/
306
306
public function isChildOf ($ node )
307
307
{
308
- $ result = ( $ this ->owner ->getAttribute ($ this ->leftAttribute ) > $ node ->getAttribute ($ this ->leftAttribute ) )
309
- && ( $ this ->owner ->getAttribute ($ this ->rightAttribute ) < $ node ->getAttribute ($ this ->rightAttribute ) );
308
+ $ result = $ this ->owner ->getAttribute ($ this ->leftAttribute ) > $ node ->getAttribute ($ this ->leftAttribute )
309
+ && $ this ->owner ->getAttribute ($ this ->rightAttribute ) < $ node ->getAttribute ($ this ->rightAttribute );
310
310
311
- if ($ this ->treeAttribute !== false ) {
312
- $ result = $ result
313
- && ($ this ->owner ->getAttribute ($ this ->treeAttribute ) === $ node ->getAttribute ($ this ->treeAttribute ));
311
+ if ($ result && $ this ->treeAttribute !== false ) {
312
+ $ result = $ this ->owner ->getAttribute ($ this ->treeAttribute ) === $ node ->getAttribute ($ this ->treeAttribute );
314
313
}
315
314
316
315
return $ result ;
@@ -448,11 +447,11 @@ public function beforeUpdate()
448
447
if ($ this ->node ->getIsNewRecord ()) {
449
448
throw new Exception ('Can not move a node when the target node is new record. ' );
450
449
}
451
-
450
+
452
451
if ($ this ->owner ->equals ($ this ->node )) {
453
452
throw new Exception ('Can not move a node when the target node is same. ' );
454
453
}
455
-
454
+
456
455
if ($ this ->node ->isChildOf ($ this ->owner )) {
457
456
throw new Exception ('Can not move a node when the target node is child. ' );
458
457
}
0 commit comments