@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | DirectoryList $directoryList |
60 | 60 | ) { |
61 | 61 | parent::__construct($context); |
62 | - $this->directoryList= $directoryList; |
|
62 | + $this->directoryList = $directoryList; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return boolean |
68 | 68 | */ |
69 | 69 | public function isActive() { |
70 | - if ( ! isset( $this->cipherActive ) ) { |
|
70 | + if ( ! isset($this->cipherActive)) { |
|
71 | 71 | $this->cipherActive = $this->scopeConfig->getValue(self::XML_PATH_CUSTOMER_CIPHER_ACTIVE) ? true : false; |
72 | 72 | } |
73 | 73 | return $this->cipherActive; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @return array |
78 | 78 | */ |
79 | 79 | private function getKeyAndIv() { |
80 | - if ( isset( $this->keyAndIv) ) { |
|
80 | + if (isset($this->keyAndIv)) { |
|
81 | 81 | return $this->keyAndIv; |
82 | 82 | } |
83 | 83 | $file = $this->directoryList->getPath('var') |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | $this->scopeConfig->getValue(self::XML_PATH_CUSTOMER_CIPHER_FILENAME). |
86 | 86 | '.php' |
87 | 87 | ; |
88 | - if ( ! is_file($file) ) { |
|
88 | + if ( ! is_file($file)) { |
|
89 | 89 | return null; |
90 | 90 | } |
91 | - $this->keyAndIv= include( $file ); |
|
91 | + $this->keyAndIv = include($file); |
|
92 | 92 | return $this->keyAndIv; |
93 | 93 | } |
94 | 94 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param string $key |
98 | 98 | * @param string $iv |
99 | 99 | */ |
100 | - public function setKeyAndIv($key,$iv) { |
|
100 | + public function setKeyAndIv($key, $iv) { |
|
101 | 101 | $this->keyAndIv = [ |
102 | 102 | 'key' => (string) $key, |
103 | 103 | 'iv' => (string) $iv, |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @param string $string |
111 | 111 | * @return string |
112 | 112 | */ |
113 | - public function cipher( $string ) { |
|
114 | - if ( ( $string === null ) || ! is_string( $string ) || ! $this->isActive() ) { |
|
113 | + public function cipher($string) { |
|
114 | + if (($string === null) || ! is_string($string) || ! $this->isActive()) { |
|
115 | 115 | return $string; |
116 | 116 | } |
117 | 117 | $keyAndIv = $this->getKeyAndIv(); |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | * @param string $string |
125 | 125 | * @return string |
126 | 126 | */ |
127 | - public function decipher( $string ) { |
|
128 | - if ( ( $string === null ) || ! is_string($string) || ! preg_match( $this->base64Pattern, $string ) ) { |
|
127 | + public function decipher($string) { |
|
128 | + if (($string === null) || ! is_string($string) || ! preg_match($this->base64Pattern, $string)) { |
|
129 | 129 | return $string; |
130 | 130 | } |
131 | 131 | $keyAndIv = $this->getKeyAndIv(); |
132 | - for ( $i = 0 ; $i < 3 ; $i++ ) { |
|
133 | - $clear = openssl_decrypt( $string, self::METHOD, $keyAndIv['key'], 0, $keyAndIv['iv'] ); |
|
134 | - if ( $clear !== false ) { |
|
132 | + for ($i = 0; $i < 3; $i++) { |
|
133 | + $clear = openssl_decrypt($string, self::METHOD, $keyAndIv['key'], 0, $keyAndIv['iv']); |
|
134 | + if ($clear !== false) { |
|
135 | 135 | $string = $clear; |
136 | 136 | } |
137 | 137 | else { |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | ) { |
40 | 40 | $this->formKeyValidator = $formKeyValidator; |
41 | 41 | $this->customerRepository = $customerRepository; |
42 | - $this->storeManager= $storeManager; |
|
42 | + $this->storeManager = $storeManager; |
|
43 | 43 | parent::__construct($context, $customerSession); |
44 | 44 | } |
45 | 45 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | public function execute() |
52 | 52 | { |
53 | 53 | $request = $this->getRequest(); |
54 | - if (!$this->formKeyValidator->validate($request)) { |
|
54 | + if ( ! $this->formKeyValidator->validate($request)) { |
|
55 | 55 | return $this->_redirect('privacy/settings/'); |
56 | 56 | } |
57 | 57 | $customerId = $this->_customerSession->getCustomerId(); |
@@ -63,8 +63,8 @@ discard block |
||
63 | 63 | /* @var $customer \Magento\Customer\Model\Data\Customer */ |
64 | 64 | $storeId = $this->storeManager->getStore()->getId(); |
65 | 65 | $customer->setStoreId($storeId); |
66 | - $customer->setCustomAttribute('personnalized_suggestions', $request->getParam('personnalized_suggestions', 0 ) ? 1 : 0 ); |
|
67 | - $customer->setCustomAttribute('third_party', $request->getParam('third_party', 0 ) ? 1 : 0 ); |
|
66 | + $customer->setCustomAttribute('personnalized_suggestions', $request->getParam('personnalized_suggestions', 0) ? 1 : 0); |
|
67 | + $customer->setCustomAttribute('third_party', $request->getParam('third_party', 0) ? 1 : 0); |
|
68 | 68 | $this->customerRepository->save($customer); |
69 | 69 | } catch (\Exception $e) { |
70 | 70 | $this->messageManager->addError(__('Something went wrong while saving your privacy settings.')); |
@@ -39,7 +39,7 @@ |
||
39 | 39 | */ |
40 | 40 | public function dispatch(RequestInterface $request) |
41 | 41 | { |
42 | - if (!$this->_customerSession->authenticate()) { |
|
42 | + if ( ! $this->_customerSession->authenticate()) { |
|
43 | 43 | $this->_actionFlag->set('', 'no-dispatch', true); |
44 | 44 | } |
45 | 45 | return parent::dispatch($request); |
@@ -56,8 +56,8 @@ |
||
56 | 56 | $customerId = $this->customerSession->getCustomerId(); |
57 | 57 | $customer = $this->customerRepository->getById($customerId); |
58 | 58 | /* @var $customer \Magento\Customer\Model\Data\Customer */ |
59 | - $block->setThirdParty( $customer->getCustomAttribute('third_party')->getValue() ); |
|
60 | - $block->setPersonnalizedSuggestions( $customer->getCustomAttribute('personnalized_suggestions')->getValue() ); |
|
59 | + $block->setThirdParty($customer->getCustomAttribute('third_party')->getValue()); |
|
60 | + $block->setPersonnalizedSuggestions($customer->getCustomAttribute('personnalized_suggestions')->getValue()); |
|
61 | 61 | return parent::_prepareLayout(); |
62 | 62 | } |
63 | 63 |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | Config $eavConfig |
78 | 78 | ) { |
79 | 79 | $this->scopeConfig = $scopeConfig; |
80 | - $this->configWriter= $configWriter; |
|
80 | + $this->configWriter = $configWriter; |
|
81 | 81 | $this->cacheTypeList = $cacheTypeList; |
82 | - $this->directoryList= $directoryList; |
|
82 | + $this->directoryList = $directoryList; |
|
83 | 83 | $this->eavSetupFactory = $eavSetupFactory; |
84 | 84 | $this->eavConfig = $eavConfig; |
85 | 85 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | { |
95 | 95 | $setup->startSetup(); |
96 | 96 | $dir = $this->directoryList->getPath('var').'/keys'; |
97 | - if ( ! is_dir( $dir ) ) { |
|
98 | - mkdir( $dir, 0700, true ); |
|
99 | - file_put_contents($dir.'/.htaccess','<IfModule !mod_authz_core.c> |
|
97 | + if ( ! is_dir($dir)) { |
|
98 | + mkdir($dir, 0700, true); |
|
99 | + file_put_contents($dir.'/.htaccess', '<IfModule !mod_authz_core.c> |
|
100 | 100 | Order deny,allow |
101 | 101 | Deny from all |
102 | 102 | </IfModule> |
@@ -104,28 +104,28 @@ discard block |
||
104 | 104 | Require all denied |
105 | 105 | </IfModule>'); |
106 | 106 | } |
107 | - $fileName = $this->scopeConfig->getValue( Cipher::XML_PATH_CUSTOMER_CIPHER_FILENAME ); |
|
108 | - if ( strlen( $fileName ) == 0 ) { |
|
109 | - $fileName = md5(microtime(true).rand(0,10000)); |
|
110 | - $this->configWriter->save( Cipher::XML_PATH_CUSTOMER_CIPHER_FILENAME, $fileName); |
|
107 | + $fileName = $this->scopeConfig->getValue(Cipher::XML_PATH_CUSTOMER_CIPHER_FILENAME); |
|
108 | + if (strlen($fileName) == 0) { |
|
109 | + $fileName = md5(microtime(true).rand(0, 10000)); |
|
110 | + $this->configWriter->save(Cipher::XML_PATH_CUSTOMER_CIPHER_FILENAME, $fileName); |
|
111 | 111 | $this->cacheTypeList->cleanType('config'); |
112 | 112 | } |
113 | 113 | $file = $dir.'/'.$fileName.'.php'; |
114 | - if ( ! is_file( $file ) ) { |
|
114 | + if ( ! is_file($file)) { |
|
115 | 115 | $isCryptoStrong = false; |
116 | - $password = openssl_random_pseudo_bytes( 64, $isCryptoStrong ); |
|
117 | - $ivlen = openssl_cipher_iv_length( Cipher::METHOD ); |
|
116 | + $password = openssl_random_pseudo_bytes(64, $isCryptoStrong); |
|
117 | + $ivlen = openssl_cipher_iv_length(Cipher::METHOD); |
|
118 | 118 | $isCryptoStrong = false; |
119 | - $iv = openssl_random_pseudo_bytes( $ivlen, $isCryptoStrong ); |
|
120 | - if( ! $isCryptoStrong ) { |
|
119 | + $iv = openssl_random_pseudo_bytes($ivlen, $isCryptoStrong); |
|
120 | + if ( ! $isCryptoStrong) { |
|
121 | 121 | throw new Exception('Non-cryptographically strong algorithm used for iv generation. This IV is not safe to use.'); |
122 | 122 | } |
123 | - file_put_contents( $file, '<?php return [\'key\'=>\''.md5($password).'\', \'iv\'=>\''.strtr($iv,['\''=>'\\\'']).'\'];' ); |
|
123 | + file_put_contents($file, '<?php return [\'key\'=>\''.md5($password).'\', \'iv\'=>\''.strtr($iv, ['\''=>'\\\'']).'\'];'); |
|
124 | 124 | chmod($file, 0700); |
125 | 125 | } |
126 | 126 | $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); |
127 | 127 | /* @var $eavSetup \Magento\Eav\Setup\EavSetup */ |
128 | - foreach( $this->customerFields as $field => $label ) { |
|
128 | + foreach ($this->customerFields as $field => $label) { |
|
129 | 129 | $eavSetup->addAttribute( |
130 | 130 | \Magento\Customer\Model\Customer::ENTITY, |
131 | 131 | $field, |
@@ -40,9 +40,9 @@ |
||
40 | 40 | public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) |
41 | 41 | { |
42 | 42 | $setup->startSetup(); |
43 | - foreach( $this->tables as $table => $columns ) { |
|
43 | + foreach ($this->tables as $table => $columns) { |
|
44 | 44 | $tableName = $setup->getTable($table); |
45 | - foreach( $columns as $column ) { |
|
45 | + foreach ($columns as $column) { |
|
46 | 46 | $setup->getConnection()->changeColumn( |
47 | 47 | $tableName, |
48 | 48 | $column, |
@@ -14,7 +14,7 @@ |
||
14 | 14 | * @param callable $proceed |
15 | 15 | * @return unknown |
16 | 16 | */ |
17 | - public function aroundReindex( AbstractModel $object, callable $proceed ) { |
|
17 | + public function aroundReindex(AbstractModel $object, callable $proceed) { |
|
18 | 18 | $this->cipher($object); |
19 | 19 | $this->cipher->setIsIndexing(true); |
20 | 20 | $return = $proceed(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return boolean |
32 | 32 | */ |
33 | 33 | protected function isActive() { |
34 | - if ( ! isset($this->active) ) { |
|
34 | + if ( ! isset($this->active)) { |
|
35 | 35 | $this->active = $this->scopeConfig->getValue(self::XML_PATH_CUSTOMER_USE_PSEUDO); |
36 | 36 | } |
37 | 37 | return $this->active; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @return \Faker\Generator |
43 | 43 | */ |
44 | 44 | protected function getFaker() { |
45 | - if ( ! isset($this->faker) ) { |
|
45 | + if ( ! isset($this->faker)) { |
|
46 | 46 | $om = \Magento\Framework\App\ObjectManager::getInstance(); |
47 | 47 | $resolver = $om->get('Magento\Framework\Locale\Resolver'); |
48 | 48 | $this->faker = Factory::create($resolver->getLocale()); |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * @param string $nickname |
57 | 57 | * @return string |
58 | 58 | */ |
59 | - public function aroundGetData( Review $review, callable $proceed, $key = '', $index = null) { |
|
59 | + public function aroundGetData(Review $review, callable $proceed, $key = '', $index = null) { |
|
60 | 60 | $result = $proceed($key, $index); |
61 | - if ( $this->isActive() && $key== 'nickname') { |
|
61 | + if ($this->isActive() && $key == 'nickname') { |
|
62 | 62 | $faker = $this->getFaker(); |
63 | 63 | return $faker->firstName; |
64 | 64 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | { |
16 | 16 | if (in_array('email', $this->fields)) { |
17 | 17 | return [ |
18 | - $this->cipher->cipher( $this->format('email', $email) ) |
|
18 | + $this->cipher->cipher($this->format('email', $email)) |
|
19 | 19 | ]; |
20 | 20 | } |
21 | 21 | return [ |