77use Illuminate \Support \Collection ;
88
99use App \Classes \LDAP \Schema \AttributeType ;
10+ use App \Ldap \Entry ;
1011
1112/**
1213 * Represents an attribute of an LDAP Object
@@ -100,9 +101,9 @@ public function __construct(string $dn,string $name,array $values,array $oc=[])
100101 {
101102 $ this ->dn = $ dn ;
102103 $ this ->name = $ name ;
103- $ this ->values_old = collect ($ values );
104+ $ this ->_values = collect ($ values );
105+ $ this ->_values_old = collect ($ values );
104106
105- $ this ->values = collect ();
106107 $ this ->oc = collect ($ oc );
107108
108109 $ this ->schema = (new Server )
@@ -149,15 +150,15 @@ public function __get(string $key): mixed
149150 // Used in Object Classes
150151 'used_in ' => $ this ->schema ?->used_in_object_classes ?: collect (),
151152 // The current attribute values
152- 'values ' => $ this ->no_attr_tags ? collect ( $ this ->_values -> first () ) : $ this ->_values ,
153+ 'values ' => $ this ->no_attr_tags ? $ this ->tagValues ( ) : $ this ->_values ,
153154 // The original attribute values
154- 'values_old ' => $ this ->no_attr_tags ? collect ( $ this ->_values_old -> first () ) : $ this ->_values_old ,
155+ 'values_old ' => $ this ->no_attr_tags ? $ this ->tagValuesOld ( ) : $ this ->_values_old ,
155156
156157 default => throw new \Exception ('Unknown key: ' . $ key ),
157158 };
158159 }
159160
160- public function __set (string $ key ,mixed $ values )
161+ public function __set (string $ key ,mixed $ values ): void
161162 {
162163 switch ($ key ) {
163164 case 'values ' :
@@ -320,14 +321,14 @@ public function render(bool $edit=FALSE,bool $old=FALSE,bool $new=FALSE): View
320321 ->with ('new ' ,$ new );
321322 }
322323
323- public function render_item_old (int $ key ): ?string
324+ public function render_item_old (string $ dotkey ): ?string
324325 {
325- return Arr::get ($ this ->values_old , $ key );
326+ return Arr::get ($ this ->_values_old -> dot (), $ dotkey );
326327 }
327328
328- public function render_item_new (int $ key ): ?string
329+ public function render_item_new (string $ dotkey ): ?string
329330 {
330- return Arr::get ($ this ->values , $ key );
331+ return Arr::get ($ this ->_values -> dot (), $ dotkey );
331332 }
332333
333334 /**
@@ -343,17 +344,17 @@ public function required(): Collection
343344 : collect ();
344345 }
345346
346- public function tagValues (string $ tag ='' ): Collection
347+ public function tagValues (string $ tag =Entry:: TAG_NOTAG ): Collection
347348 {
348- return $ this ->_values
349- ->filter (fn ($ item ,$ key )=>($ key === $ tag ))
350- ->values ( );
349+ return collect ( $ this ->_values
350+ ->filter (fn ($ item ,$ key )=>($ key ===$ tag ))
351+ ->get ( $ tag ,[]) );
351352 }
352353
353- public function tagValuesOld (string $ tag ='' ): Collection
354+ public function tagValuesOld (string $ tag =Entry:: TAG_NOTAG ): Collection
354355 {
355- return $ this ->_values_old
356- ->filter (fn ($ item ,$ key )=>($ key === $ tag ))
357- ->values ( );
356+ return collect ( $ this ->_values_old
357+ ->filter (fn ($ item ,$ key )=>($ key ===$ tag ))
358+ ->get ( $ tag ,[]) );
358359 }
359360}
0 commit comments