File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed
Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,7 @@ public function getCpNavItem(): ?array
158158
159159 private function registerWidgets (): void
160160 {
161- if (! $ this ->settings ->hasApiCredentials ()) {
161+ if (! $ this ->getSettings () ->hasApiCredentials ()) {
162162 return ;
163163 }
164164
Original file line number Diff line number Diff line change @@ -55,15 +55,15 @@ public function behaviors(): array
5555 */
5656 public function hasApiCredentials (): bool
5757 {
58- return ! empty ($ this ->apiToken ) && ! empty ($ this ->selectedSiteId );
58+ return ! empty ($ this ->apiToken ) && ! empty ($ this ->selectedSiteId ) && ! empty ( $ this -> getApiToken ()) && ! empty ( $ this -> getSelectedSiteId ()) ;
5959 }
6060
61- public function getApiToken (): string
61+ public function getApiToken (): ? string
6262 {
6363 return App::parseEnv ($ this ->apiToken );
6464 }
6565
66- public function getSelectedSiteId (): string
66+ public function getSelectedSiteId (): ? string
6767 {
6868 return App::parseEnv ($ this ->selectedSiteId );
6969 }
Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ class OhDearService extends Component
4949 public function __construct ($ config = [])
5050 {
5151 parent ::__construct ($ config );
52+
53+ if (! OhDear::$ plugin ->getSettings ()->hasApiCredentials ()) {
54+ throw new Exception ('Oh Dear credentials are not set. Please check your settings. ' );
55+ }
5256
5357 $ this ->monitorId = intval (OhDear::$ plugin ->getSettings ()->getSelectedSiteId ());
5458 $ this ->apiToken = OhDear::$ plugin ->getSettings ()->getApiToken ();
You can’t perform that action at this time.
0 commit comments