@@ -146,15 +146,28 @@ public function setAuthenticator(IAuthenticator $handler)
146146 /**
147147 * Returns authentication handler.
148148 */
149- final public function getAuthenticator (bool $ throw = true ): ?IAuthenticator
149+ final public function getAuthenticator (): ?IAuthenticator
150150 {
151- if ($ throw && !$ this ->authenticator ) {
151+ if (func_num_args ()) {
152+ trigger_error (__METHOD__ . '() parameter $throw is deprecated, use hasAuthenticator() ' , E_USER_DEPRECATED );
153+ $ throw = func_get_arg (0 );
154+ }
155+ if (($ throw ?? true ) && !$ this ->authenticator ) {
152156 throw new Nette \InvalidStateException ('Authenticator has not been set. ' );
153157 }
154158 return $ this ->authenticator ;
155159 }
156160
157161
162+ /**
163+ * Does the authentication exist?
164+ */
165+ final public function hasAuthenticator (): bool
166+ {
167+ return (bool ) $ this ->authenticator ;
168+ }
169+
170+
158171 /**
159172 * Enables log out after inactivity (like '20 minutes'). Accepts flag IUserStorage::CLEAR_IDENTITY.
160173 * @param string|null $expire
@@ -244,11 +257,24 @@ public function setAuthorizator(IAuthorizator $handler)
244257 /**
245258 * Returns current authorization handler.
246259 */
247- final public function getAuthorizator (bool $ throw = true ): ?IAuthorizator
260+ final public function getAuthorizator (): ?IAuthorizator
248261 {
249- if ($ throw && !$ this ->authorizator ) {
262+ if (func_num_args ()) {
263+ trigger_error (__METHOD__ . '() parameter $throw is deprecated, use hasAuthorizator() ' , E_USER_DEPRECATED );
264+ $ throw = func_get_arg (0 );
265+ }
266+ if (($ throw ?? true ) && !$ this ->authorizator ) {
250267 throw new Nette \InvalidStateException ('Authorizator has not been set. ' );
251268 }
252269 return $ this ->authorizator ;
253270 }
271+
272+
273+ /**
274+ * Does the authorization exist?
275+ */
276+ final public function hasAuthorizator (): bool
277+ {
278+ return (bool ) $ this ->authorizator ;
279+ }
254280}
0 commit comments