@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | if ($access_token_entity) { |
67 | 67 | |
68 | 68 | $this->request->session()->write([ |
69 | - 'shopify_access_token_'.$this->ShopifyAPI->api_key => $access_token, |
|
70 | - 'shopify_shop_domain_'.$this->ShopifyAPI->api_key => $this->ShopifyAPI->getShopDomain() |
|
69 | + 'shopify_access_token_' . $this->ShopifyAPI->api_key => $access_token, |
|
70 | + 'shopify_shop_domain_' . $this->ShopifyAPI->api_key => $this->ShopifyAPI->getShopDomain() |
|
71 | 71 | ]); |
72 | 72 | |
73 | 73 | //$this->Auth->setUser($shop_entity); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if ($valid_domain) { |
118 | 118 | |
119 | 119 | $this->request->session()->write([ |
120 | - 'shopify_shop_domain_'.$this->ShopifyAPI->api_key => $this->request->data['shop_domain'] |
|
120 | + 'shopify_shop_domain_' . $this->ShopifyAPI->api_key => $this->request->data['shop_domain'] |
|
121 | 121 | ]); |
122 | 122 | |
123 | 123 | $redirect_url = Router::url([ |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | return $this->callLimit() - $this->callsMade(); |
67 | 67 | } |
68 | 68 | |
69 | - public function call($method, $path, $params=array()) { |
|
69 | + public function call($method, $path, $params = array()) { |
|
70 | 70 | |
71 | 71 | if (!$this->_isReady()) { |
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - if (!in_array($method, array('POST','PUT','GET','DELETE'))) { |
|
75 | + if (!in_array($method, array('POST', 'PUT', 'GET', 'DELETE'))) { |
|
76 | 76 | return false; |
77 | 77 | } |
78 | 78 | |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | |
86 | 86 | $this->response = $http->{strtolower($method)}( |
87 | 87 | $path, |
88 | - ((in_array($method, array('POST','PUT'))) ? json_encode($params) : $params), |
|
89 | - ((in_array($method, array('POST','PUT'))) ? ['type' => 'json'] : []) |
|
88 | + ((in_array($method, array('POST', 'PUT'))) ? json_encode($params) : $params), |
|
89 | + ((in_array($method, array('POST', 'PUT'))) ? ['type' => 'json'] : []) |
|
90 | 90 | ); |
91 | 91 | $this->response = $this->response->json; |
92 | 92 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | } |
96 | 96 | |
97 | 97 | private function shopApiCallLimitParam($index) { |
98 | - $params = explode("/",$this->response->getHeaderLine('http_x_shopify_shop_api_call_limit')); |
|
98 | + $params = explode("/", $this->response->getHeaderLine('http_x_shopify_shop_api_call_limit')); |
|
99 | 99 | return (int) $params[$index]; |
100 | 100 | } |
101 | 101 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $response = $http->post('/admin/oauth/access_token', 'client_id=' . $this->api_key . |
122 | 122 | '&client_secret=' . $this->shared_secret . |
123 | 123 | '&code=' . $code); |
124 | - $response = $response->json;; |
|
124 | + $response = $response->json; ; |
|
125 | 125 | |
126 | 126 | if (isset($response['access_token'])) { |
127 | 127 | $this->token = $response['access_token']; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $query = $this->access_tokens->find(); |
100 | 100 | $query = $query->contain(['Shops']); |
101 | 101 | $query = $query->where(['api_key' => $api_key, 'token' => $access_token]); |
102 | - $query = $query->where(function ($exp, $q) { |
|
102 | + $query = $query->where(function($exp, $q) { |
|
103 | 103 | return $exp->isNull('expired_at'); |
104 | 104 | }); |
105 | 105 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $query = $this->access_tokens->find(); |
119 | 119 | $query = $query->contain(['Shops']); |
120 | 120 | $query = $query->where(['api_key' => $api_key, 'Shops.myshopify_domain' => $shop_domain]); |
121 | - $query = $query->where(function ($exp, $q) { |
|
121 | + $query = $query->where(function($exp, $q) { |
|
122 | 122 | return $exp->isNull('expired_at'); |
123 | 123 | }); |
124 | 124 |
@@ -23,26 +23,26 @@ |
||
23 | 23 | |
24 | 24 | public function output($data, $columns = 10, $terminal_width = 80) |
25 | 25 | { |
26 | - while((count($data)%$columns != 0) && ($columns > 5)) { |
|
26 | + while ((count($data) % $columns != 0) && ($columns > 5)) { |
|
27 | 27 | $columns--; |
28 | 28 | } |
29 | 29 | |
30 | 30 | $max_length = max(array_map('strlen', $data)); |
31 | 31 | |
32 | - while(((($columns * ($max_length+3)) + 3) > $terminal_width) && ($columns >= 1)) { |
|
32 | + while (((($columns * ($max_length + 3)) + 3) > $terminal_width) && ($columns >= 1)) { |
|
33 | 33 | $columns--; |
34 | 34 | } |
35 | 35 | |
36 | 36 | $this->_io->out(' ' . str_repeat('+-' . str_repeat('-', $max_length) . '-', $columns) . '+ '); |
37 | 37 | |
38 | - for($i = 0; $i < count($data); ) { |
|
38 | + for ($i = 0; $i < count($data);) { |
|
39 | 39 | $output = " "; |
40 | 40 | $j = $i; |
41 | - for($k = $i; $k < ($columns+$j); $k++) { |
|
41 | + for ($k = $i; $k < ($columns + $j); $k++) { |
|
42 | 42 | if (!isset($data[$i])) { |
43 | 43 | $data[$i] = ''; |
44 | 44 | } |
45 | - $output .= '| ' . str_repeat(' ', floor(($max_length - strlen($data[$i]))/2)) . $data[$i] . str_repeat(' ', ceil(($max_length - strlen($data[$i]))/2)) . ' '; |
|
45 | + $output .= '| ' . str_repeat(' ', floor(($max_length - strlen($data[$i])) / 2)) . $data[$i] . str_repeat(' ', ceil(($max_length - strlen($data[$i])) / 2)) . ' '; |
|
46 | 46 | $i++; |
47 | 47 | } |
48 | 48 | $this->_io->out($output . '|'); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $first_run = ((Configure::check('Shopify')) ? false : true); |
35 | 35 | |
36 | 36 | //Activate Plugin |
37 | - if ((($first_run) ? (strtolower($this->in('Install Shopify Plugin?', ['y','n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y','n'])) == 'y'))) { |
|
37 | + if ((($first_run) ? (strtolower($this->in('Install Shopify Plugin?', ['y', 'n'])) == 'y') : (strtolower($this->in('Update Configuration?', ['y', 'n'])) == 'y'))) { |
|
38 | 38 | |
39 | 39 | $this->out(); |
40 | 40 | $this->out('Please enter your API credentials from your Shopify App page.', 2); |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | $this->_io->out('<error>Invalid Scope. Try again, or leave blank to continue.</error>'); |
73 | 73 | } |
74 | 74 | |
75 | - } while((count($scope)) && (strlen(trim(implode("", $scope))) > 0) && (count(array_diff($scope, $scope_array)) > 0)); |
|
75 | + } while ((count($scope)) && (strlen(trim(implode("", $scope))) > 0) && (count(array_diff($scope, $scope_array)) > 0)); |
|
76 | 76 | |
77 | - Configure::write('Shopify.' . $api_key . '.scope',implode(',', $scope)); |
|
77 | + Configure::write('Shopify.' . $api_key . '.scope', implode(',', $scope)); |
|
78 | 78 | |
79 | 79 | $this->out(''); |
80 | - $is_private_app = strtolower($this->in('Is this a private app?', ['y','n'])); |
|
80 | + $is_private_app = strtolower($this->in('Is this a private app?', ['y', 'n'])); |
|
81 | 81 | |
82 | 82 | if ($is_private_app == 'y') { |
83 | 83 | $is_private_app = 'true'; |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | $is_private_app = 'false'; |
86 | 86 | } |
87 | 87 | |
88 | - Configure::write('Shopify.' . $api_key . '.is_private_app',$is_private_app); |
|
88 | + Configure::write('Shopify.' . $api_key . '.is_private_app', $is_private_app); |
|
89 | 89 | |
90 | 90 | if ($is_private_app == 'true') { |
91 | - Configure::write('Shopify.' . $api_key . '.private_app_password',$this->in('Private App Password:')); |
|
91 | + Configure::write('Shopify.' . $api_key . '.private_app_password', $this->in('Private App Password:')); |
|
92 | 92 | } else { |
93 | 93 | Configure::write('Shopify.' . $api_key . '.private_app_password', NULL); |
94 | 94 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | $this->out(''); |
101 | 101 | |
102 | - if (($first_run) || (strtolower($this->in('Update Database?', ['y','n'])) == 'y')) { |
|
102 | + if (($first_run) || (strtolower($this->in('Update Database?', ['y', 'n'])) == 'y')) { |
|
103 | 103 | |
104 | 104 | $this->out(''); |
105 | 105 | |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | |
110 | 110 | if ((is_array($status)) && (count($status))) { |
111 | 111 | |
112 | - $this->out('Updating Databases',2); |
|
112 | + $this->out('Updating Databases', 2); |
|
113 | 113 | |
114 | 114 | if ($migrations->migrate()) { |
115 | - $this->out('Success!',2); |
|
115 | + $this->out('Success!', 2); |
|
116 | 116 | } else { |
117 | 117 | $this->_io->out('<error>Update Failed!</error>', 2); |
118 | 118 | } |
119 | 119 | |
120 | 120 | } else { |
121 | - $this->out('Shopify Database Files Not Found',2); |
|
121 | + $this->out('Shopify Database Files Not Found', 2); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | } |
@@ -113,7 +113,7 @@ |
||
113 | 113 | |
114 | 114 | $shop = $this->ShopifyDatabase->getShopDataFromAccessToken($accessToken, $this->api_key); |
115 | 115 | |
116 | - if($shop && is_array($shop)){ |
|
116 | + if ($shop && is_array($shop)) { |
|
117 | 117 | return ['id' => $shop['id'], 'username' => $shop['myshopify_domain']]; |
118 | 118 | } |
119 | 119 |