File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -141,24 +141,31 @@ public function beforeFilter(EventInterface $event)
141141 {
142142 $ controllerName = $ this ->request ->getParam ('controller ' );
143143 $ this ->set ('current_controller ' , $ controllerName );
144- $ notif_count = 0 ;
145144
146145 $ devId = $ this ->request ->getSession ()->read ('Developer.id ' );
147- if ($ devId ) {
146+ if ($ devId !== null ) {
148147 $ response = $ this ->checkReadonlyAccess ();
149148 if ($ response !== null ) {
150149 // This is a security check
151150 // The response can be printed if you remove this line
152151 return $ response ;
153152 }
153+ }
154154
155+ $ current_developer = null ;
156+ if ($ devId !== null ) {
157+ // Check if the user still exists in the database
155158 $ current_developer = TableRegistry::getTableLocator ()->get ('Developers ' )->
156159 findById ($ devId )->all ()->first ();
160+ }
157161
162+ $ notif_count = 0 ;
163+ if ($ current_developer !== null ) {
158164 $ notif_count = TableRegistry::getTableLocator ()->get ('Notifications ' )->find (
159165 'all ' ,
160- conditions: ['developer_id ' => ( int ) isset ( $ current_developer) ? $ current_developer ['id ' ] : null ]
166+ conditions: ['developer_id ' => $ current_developer ['id ' ]]
161167 )->count ();
168+
162169 $ this ->set ('current_developer ' , $ current_developer );
163170 $ this ->set ('developer_signed_in ' , true );
164171
You can’t perform that action at this time.
0 commit comments