@@ -66,6 +66,10 @@ discard block |
||
| 66 | 66 | return $this->callLimit() - $this->callsMade(); |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | + /** |
|
| 70 | + * @param string $method |
|
| 71 | + * @param string $path |
|
| 72 | + */ |
|
| 69 | 73 | public function call($method, $path, $params=array()) { |
| 70 | 74 | |
| 71 | 75 | if (!$this->_isReady()) { |
@@ -94,6 +98,9 @@ discard block |
||
| 94 | 98 | |
| 95 | 99 | } |
| 96 | 100 | |
| 101 | + /** |
|
| 102 | + * @param integer $index |
|
| 103 | + */ |
|
| 97 | 104 | private function shopApiCallLimitParam($index) { |
| 98 | 105 | $params = explode("/",$this->response->getHeaderLine('http_x_shopify_shop_api_call_limit')); |
| 99 | 106 | return (int) $params[$index]; |
@@ -179,6 +186,9 @@ discard block |
||
| 179 | 186 | |
| 180 | 187 | } |
| 181 | 188 | |
| 189 | + /** |
|
| 190 | + * @param string $url |
|
| 191 | + */ |
|
| 182 | 192 | private function _urlEncode($url) { |
| 183 | 193 | |
| 184 | 194 | $url = str_replace('&', '%26', $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']; |
@@ -38,24 +38,24 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | $this->api_key = isset($config['api_key']) ? $config['api_key'] : ''; |
| 40 | 40 | |
| 41 | - if (!empty($this->api_key)) { |
|
| 41 | + if (!empty($this->api_key)) { |
|
| 42 | 42 | |
| 43 | - $this->shared_secret = Configure::read('Multidimensional/Shopify.' . $this->api_key . '.shared_secret'); |
|
| 44 | - $this->scope = Configure::read('Multidimensional/Shopify.' . $this->api_key . '.scope'); |
|
| 45 | - $this->is_private_app = Configure::read('Multidimensional/Shopify.' . $this->api_key . '.is_private_app'); |
|
| 46 | - $this->private_app_password = Configure::read('Multidimensional/Shopify.' . $this->api_key . '.private_app_password'); |
|
| 43 | + $this->shared_secret = Configure::read('Multidimensional/Shopify.' . $this->api_key . '.shared_secret'); |
|
| 44 | + $this->scope = Configure::read('Multidimensional/Shopify.' . $this->api_key . '.scope'); |
|
| 45 | + $this->is_private_app = Configure::read('Multidimensional/Shopify.' . $this->api_key . '.is_private_app'); |
|
| 46 | + $this->private_app_password = Configure::read('Multidimensional/Shopify.' . $this->api_key . '.private_app_password'); |
|
| 47 | 47 | |
| 48 | - } else { |
|
| 48 | + } else { |
|
| 49 | 49 | |
| 50 | - throw new NotImplementedException(__('Shopify API key not found')); |
|
| 50 | + throw new NotImplementedException(__('Shopify API key not found')); |
|
| 51 | 51 | |
| 52 | - } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - if (!$this->shared_secret) { |
|
| 54 | + if (!$this->shared_secret) { |
|
| 55 | 55 | |
| 56 | - throw new NotImplementedException(__('Shopify shared secret not found')); |
|
| 56 | + throw new NotImplementedException(__('Shopify shared secret not found')); |
|
| 57 | 57 | |
| 58 | - } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | } |
| 61 | 61 | |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | return false; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | 152 | public function setNonce($shop_domain) { |
| 153 | 153 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | $string = implode("&", $dataString); |
| 195 | 195 | return $query['hmac'] == hash_hmac('sha256', $string, $this->shared_secret); |
| 196 | 196 | |
| 197 | - } |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | 199 | private function _urlEncode($url) { |
| 200 | 200 | |
@@ -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([ |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | 'shopify_shop_domain_'.$this->ShopifyAPI->api_key => $this->ShopifyAPI->getShopDomain() |
| 71 | 71 | ]); |
| 72 | 72 | |
| 73 | - $this->Auth->setUser($shop_entity); |
|
| 73 | + $this->Auth->setUser($shop_entity); |
|
| 74 | 74 | |
| 75 | 75 | return $this->redirect([ |
| 76 | 76 | 'controller' => 'Shopify', |
| 77 | 77 | 'plugin' => false, |
| 78 | - 'api_key' => $this->ShopifyAPI->api_key]); |
|
| 78 | + 'api_key' => $this->ShopifyAPI->api_key]); |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | 81 | } else { |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | $this->render('add'); |
| 111 | 111 | |
| 112 | - } elseif (!empty($this->request->data['shop_domain']) && !$this->error) { |
|
| 112 | + } elseif (!empty($this->request->data['shop_domain']) && !$this->error) { |
|
| 113 | 113 | |
| 114 | 114 | $valid_domain = $this->ShopifyAPI->validDomain( |
| 115 | 115 | $this->request->data['shop_domain'] |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | * Initialize AppController |
| 25 | 25 | * |
| 26 | 26 | * @return void |
| 27 | - */ |
|
| 27 | + */ |
|
| 28 | 28 | public function initialize() |
| 29 | 29 | { |
| 30 | 30 | parent::initialize(); |
@@ -17,16 +17,14 @@ |
||
| 17 | 17 | |
| 18 | 18 | use App\Controller\AppController as BaseController; |
| 19 | 19 | |
| 20 | -class AppController extends BaseController |
|
| 21 | -{ |
|
| 20 | +class AppController extends BaseController { |
|
| 22 | 21 | |
| 23 | 22 | /** |
| 24 | 23 | * Initialize AppController |
| 25 | 24 | * |
| 26 | 25 | * @return void |
| 27 | 26 | */ |
| 28 | - public function initialize() |
|
| 29 | - { |
|
| 27 | + public function initialize() { |
|
| 30 | 28 | parent::initialize(); |
| 31 | 29 | $this->loadComponent('Flash'); |
| 32 | 30 | } |
@@ -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 | |
@@ -68,8 +68,7 @@ |
||
| 68 | 68 | * @property bool $setup_required |
| 69 | 69 | * @property bool $force_ssl |
| 70 | 70 | */ |
| 71 | -class Shop extends Entity |
|
| 72 | -{ |
|
| 71 | +class Shop extends Entity { |
|
| 73 | 72 | |
| 74 | 73 | /** |
| 75 | 74 | * Fields that can be mass assigned using newEntity() or patchEntity(). |
@@ -27,8 +27,7 @@ |
||
| 27 | 27 | * @property \Cake\I18n\Time $updated_at |
| 28 | 28 | * @property \Cake\I18n\Time $expired_at |
| 29 | 29 | */ |
| 30 | -class AccessToken extends Entity |
|
| 31 | -{ |
|
| 30 | +class AccessToken extends Entity { |
|
| 32 | 31 | |
| 33 | 32 | /** |
| 34 | 33 | * Fields that can be mass assigned using newEntity() or patchEntity(). |
@@ -31,8 +31,7 @@ discard block |
||
| 31 | 31 | * @method \Shopify\Model\Entity\AccessToken[] patchEntities($entities, array $data, array $options = []) |
| 32 | 32 | * @method \Shopify\Model\Entity\AccessToken findOrCreate($search, callable $callback = null) |
| 33 | 33 | */ |
| 34 | -class AccessTokensTable extends Table |
|
| 35 | -{ |
|
| 34 | +class AccessTokensTable extends Table { |
|
| 36 | 35 | |
| 37 | 36 | /** |
| 38 | 37 | * Initialize method |
@@ -40,8 +39,7 @@ discard block |
||
| 40 | 39 | * @param array $config The configuration for the Table. |
| 41 | 40 | * @return void |
| 42 | 41 | */ |
| 43 | - public function initialize(array $config) |
|
| 44 | - { |
|
| 42 | + public function initialize(array $config) { |
|
| 45 | 43 | parent::initialize($config); |
| 46 | 44 | |
| 47 | 45 | //$this->table('access_tokens'); |
@@ -58,8 +56,7 @@ discard block |
||
| 58 | 56 | * @param \Cake\Validation\Validator $validator Validator instance. |
| 59 | 57 | * @return \Cake\Validation\Validator |
| 60 | 58 | */ |
| 61 | - public function validationDefault(Validator $validator) |
|
| 62 | - { |
|
| 59 | + public function validationDefault(Validator $validator) { |
|
| 63 | 60 | $validator |
| 64 | 61 | ->integer('id') |
| 65 | 62 | ->allowEmpty('id', 'create'); |
@@ -101,8 +98,7 @@ discard block |
||
| 101 | 98 | * @param \Cake\ORM\RulesChecker $rules The rules object to be modified. |
| 102 | 99 | * @return \Cake\ORM\RulesChecker |
| 103 | 100 | */ |
| 104 | - public function buildRules(RulesChecker $rules) |
|
| 105 | - { |
|
| 101 | + public function buildRules(RulesChecker $rules) { |
|
| 106 | 102 | $rules->add($rules->isUnique(['token'])); |
| 107 | 103 | |
| 108 | 104 | return $rules; |
@@ -31,8 +31,7 @@ discard block |
||
| 31 | 31 | * @method \App\Model\Entity\Shop[] patchEntities($entities, array $data, array $options = []) |
| 32 | 32 | * @method \App\Model\Entity\Shop findOrCreate($search, callable $callback = null) |
| 33 | 33 | */ |
| 34 | -class ShopsTable extends Table |
|
| 35 | -{ |
|
| 34 | +class ShopsTable extends Table { |
|
| 36 | 35 | |
| 37 | 36 | /** |
| 38 | 37 | * Initialize method |
@@ -40,8 +39,7 @@ discard block |
||
| 40 | 39 | * @param array $config The configuration for the Table. |
| 41 | 40 | * @return void |
| 42 | 41 | */ |
| 43 | - public function initialize(array $config) |
|
| 44 | - { |
|
| 42 | + public function initialize(array $config) { |
|
| 45 | 43 | parent::initialize($config); |
| 46 | 44 | |
| 47 | 45 | //$this->table('shops'); |
@@ -60,8 +58,7 @@ discard block |
||
| 60 | 58 | * @param \Cake\Validation\Validator $validator Validator instance. |
| 61 | 59 | * @return \Cake\Validation\Validator |
| 62 | 60 | */ |
| 63 | - public function validationDefault(Validator $validator) |
|
| 64 | - { |
|
| 61 | + public function validationDefault(Validator $validator) { |
|
| 65 | 62 | $validator |
| 66 | 63 | ->integer('id') |
| 67 | 64 | ->allowEmpty('id', 'create'); |
@@ -258,8 +255,7 @@ discard block |
||
| 258 | 255 | * @param \Cake\ORM\RulesChecker $rules The rules object to be modified. |
| 259 | 256 | * @return \Cake\ORM\RulesChecker |
| 260 | 257 | */ |
| 261 | - public function buildRules(RulesChecker $rules) |
|
| 262 | - { |
|
| 258 | + public function buildRules(RulesChecker $rules) { |
|
| 263 | 259 | $rules->add($rules->isUnique(['email'])); |
| 264 | 260 | |
| 265 | 261 | return $rules; |
@@ -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 . '|'); |
@@ -18,11 +18,9 @@ |
||
| 18 | 18 | use Cake\Console\Shell; |
| 19 | 19 | use Cake\Console\Helper; |
| 20 | 20 | |
| 21 | -class TableHelper extends Helper |
|
| 22 | -{ |
|
| 21 | +class TableHelper extends Helper { |
|
| 23 | 22 | |
| 24 | - public function output($data, $columns = 10, $terminal_width = 80) |
|
| 25 | - { |
|
| 23 | + public function output($data, $columns = 10, $terminal_width = 80) { |
|
| 26 | 24 | while((count($data)%$columns != 0) && ($columns > 5)) { |
| 27 | 25 | $columns--; |
| 28 | 26 | } |