File tree Expand file tree Collapse file tree 1 file changed +21
-11
lines changed Expand file tree Collapse file tree 1 file changed +21
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace FullscreenInteractive \SilverStripeXero ;
4
4
5
+ use Exception ;
5
6
use SilverStripe \Core \Environment ;
6
7
use SilverStripe \Forms \DropdownField ;
7
8
use SilverStripe \Forms \FieldList ;
9
+ use SilverStripe \Forms \LiteralField ;
8
10
use SilverStripe \Forms \ReadonlyField ;
9
11
use SilverStripe \ORM \DataExtension ;
10
12
use SilverStripe \Security \Permission ;
@@ -39,19 +41,27 @@ public function updateCMSFields(FieldList $fields)
39
41
40
42
if ($ this ->owner ->XeroAccessToken ) {
41
43
$ tenants = [];
42
- $ tenantRecords = XeroFactory::singleton ()->getTenants ($ this ->owner ->XeroAccessToken );
43
44
44
- foreach ($ tenantRecords as $ tenant ) {
45
- $ tenants [$ tenant ->tenantId ] = $ tenant ->tenantName ;
46
- }
45
+ try {
46
+ $ tenantRecords = XeroFactory::singleton ()->getTenants ($ this ->owner ->XeroAccessToken );
47
+
48
+ foreach ($ tenantRecords as $ tenant ) {
49
+ $ tenants [$ tenant ->tenantId ] = $ tenant ->tenantName ;
50
+ }
47
51
48
- $ fields ->addFieldsToTab ('Root.Xero ' , [
49
- DropdownField::create (
50
- 'XeroTenantId ' ,
51
- 'Xero Tenant ' ,
52
- $ tenants
53
- )
54
- ]);
52
+ $ fields ->addFieldsToTab ('Root.Xero ' , [
53
+ DropdownField::create (
54
+ 'XeroTenantId ' ,
55
+ 'Xero Tenant ' ,
56
+ $ tenants
57
+ )
58
+ ]);
59
+ } catch (Exception $ e ) {
60
+ $ fields ->addFieldsToTab ('Root.Xero ' , LiteralField::create (
61
+ 'XeroError ' ,
62
+ 'An error has occured connecting to xero: ' . $ e ->getMessage ()
63
+ ));
64
+ }
55
65
}
56
66
}
57
67
}
You can’t perform that action at this time.
0 commit comments