88use OWC \Zaaksysteem \Contracts \Client ;
99use OWC \Zaaksysteem \Endpoints \Filter \TakenFilter ;
1010use OWC \Zaaksysteem \Endpoints \Filter \ZakenFilter ;
11- use OWC \Zaaksysteem \Resolvers \ContainerResolver ;
12- use OWC \Zaaksysteem \Support \Collection ;
13-
1411use function OWC \Zaaksysteem \Foundation \Helpers \resolve ;
1512use function OWC \Zaaksysteem \Foundation \Helpers \view ;
1613
14+ use OWC \Zaaksysteem \Resolvers \ContainerResolver ;
15+ use OWC \Zaaksysteem \Support \Collection ;
16+
1717class Block
1818{
1919 protected Client $ client ;
@@ -64,11 +64,11 @@ protected function getCurrentUserBsn(): string
6464 * TEMP: signicat plugin has some changes pending which requires another implementation.
6565 */
6666 if (empty ($ bsn )) {
67- $ isLoggedIn = apply_filters ('owc_siginicat_openid_is_user_logged_in ' , false , 'digid ' );
67+ $ isLoggedIn = apply_filters ('owc_digid_is_logged_in ' , false , 'digid ' );
6868
6969 if ($ isLoggedIn ) {
70- $ userInfo = apply_filters ('owc_signicat_openid_user_info ' , [] , 'digid ' );
71- $ bsn = $ userInfo[ ' sub ' ] ?? '' ;
70+ $ userInfo = apply_filters ('owc_digid_userdata ' , null , 'digid ' );
71+ $ bsn = $ userInfo-> getBsn () ;
7272 }
7373
7474 return ! empty ($ bsn ) && is_string ($ bsn ) ? $ bsn : '' ;
@@ -97,20 +97,21 @@ protected function uniqueTransientKey(array $attributes): string
9797
9898 protected function getZaken (array $ attributes ): Collection
9999 {
100- return Collection::collect ([
101- 'https://api.accept.common-gateway.commonground.nu/api/zrc/v1/zaken/f5d1c9b7-e3a9-485d-98cb-1667e1d0537c '
102- ]);
100+ // return Collection::collect([
101+ // 'https://api.accept.common-gateway.commonground.nu/api/zrc/v1/zaken/f5d1c9b7-e3a9-485d-98cb-1667e1d0537c',
102+ // ]);
103103
104+ // return $this->client->zaken()->all();
104105 // When mijn-taken api is properly configured this should be activated again.
105- // $filter = new ZakenFilter();
106- // $filter = $this->handleFilterBSN($filter, $attributes);
106+ $ filter = new ZakenFilter ();
107+ $ filter = $ this ->handleFilterBSN ($ filter , $ attributes );
107108
108- // return $this->client->zaken()->filter($filter);
109+ return $ this ->client ->zaken ()->filter ($ filter );
109110 }
110111
111112 protected function handleFilterBSN (ZakenFilter $ filter , array $ attributes ): ZakenFilter
112113 {
113- if (! $ attributes ['byBSN ' ]) {
114+ if (! ( $ attributes ['byBSN ' ] ?? false ) ) {
114115 return $ filter ;
115116 }
116117
@@ -125,14 +126,14 @@ protected function getTaken(Collection $zaken): Collection
125126
126127 foreach ($ zaken as $ zaak ) {
127128 $ filter = new TakenFilter ();
128- // $filter->byZaak($zaak->url);
129- $ filter ->byZaakURL ($ zaak ); // Above should be activated again when the mijn-taken api is properly configured.
129+ $ filter ->byZaak ($ zaak );
130130 $ fetchedTaken = $ this ->client ->taken ()->filter ($ filter );
131131
132132 if ($ fetchedTaken ->isNotEmpty ()) {
133133 $ taken [] = $ fetchedTaken ->toArray ();
134134 }
135135 }
136+ // Misschien nog filteren hier?
136137
137138 return Collection::collect ($ taken )->flattenAndAssign (function ($ carry , $ item ) {
138139 if (is_array ($ item )) {
@@ -147,7 +148,7 @@ protected function getTaken(Collection $zaken): Collection
147148
148149 protected function returnView (array $ attributes , Collection $ taken ): string
149150 {
150- if ($ attributes [ ' view ' ] === ' default ' ) {
151+ if (' default ' === $ attributes [ ' view ' ] ) {
151152 return view ('blocks/mijn-taken/overview-taken.php ' , ['taken ' => $ taken ]);
152153 }
153154
0 commit comments