@@ -18,7 +18,7 @@ class Complex extends AbstractComplex
18
18
*/
19
19
public function getSchemas ()
20
20
{
21
- return collect ($ this ->getSchemaNodes ())->map (fn ($ element ) => $ element ->name )->values ()->toArray ();
21
+ return collect ($ this ->getSchemaNodes ())->map (fn ($ element ) => $ element ->name )->values ()->toArray ();
22
22
}
23
23
24
24
@@ -76,21 +76,29 @@ public function patch($operation, $value, Model &$object, Path $path = null, $re
76
76
$ attributeNames = $ path ?->getAttributePath()?->getAttributeNames() ?? [];
77
77
78
78
if (!empty ($ attributeNames )) {
79
- $ attribute = $ this ->getSubNode ($ attributeNames [0 ]);
79
+ $ schema = $ path ->getAttributePath ()?->path?->schema;
80
+ // Resolve attribute either directly or via schema parent when specified
81
+ $ attribute = $ schema
82
+ ? ((($ parent = $ this ->getSubNode ($ schema )) instanceof Schema) ? $ parent ->getSubNode ($ attributeNames [0 ]) : null )
83
+ : $ this ->getSubNode ($ attributeNames [0 ]);
84
+
80
85
if ($ attribute != null ) {
81
86
$ attribute ->patch ($ operation , $ value , $ object , $ path ->shiftAttributePathAttributes ());
82
- } elseif ($ this ->parent == null ) {
83
- // this is the root node, check within the first (the default) schema node
84
- // pass the unchanged path object
87
+ return ; // done
88
+ }
89
+
90
+ if ($ this ->parent == null ) {
91
+ // root node: delegate unchanged path to default schema node
85
92
$ this ->getSchemaNode ()->patch ($ operation , $ value , $ object , $ path );
86
- } else {
87
- throw new SCIMException ('Unknown path: ' . (string )$ path . ", in object: " . $ this ->getFullKey ());
93
+ return ; // done
88
94
}
95
+
96
+ throw new SCIMException ('Unknown path: ' . (string )$ path . ", in object: " . $ this ->getFullKey ());
89
97
}
90
98
}
91
99
} else {
92
100
// if there is no path, keys of value are attribute names
93
- switch ($ operation ) {
101
+ switch ($ operation ) {
94
102
case 'replace ' :
95
103
$ this ->replace ($ value , $ object , $ path , false );
96
104
break ;
@@ -300,6 +308,6 @@ public function applyComparison(Builder &$query, Path $path, $parentAttribute =
300
308
*/
301
309
public function getDefaultSchema ()
302
310
{
303
- return collect ($ this ->subAttributes )->first (fn ($ element ) => $ element instanceof Schema)->name ;
311
+ return collect ($ this ->subAttributes )->first (fn ($ element ) => $ element instanceof Schema)->name ;
304
312
}
305
313
}
0 commit comments