@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | public function getThirdPartyActive() |
| 51 | 51 | { |
| 52 | - if ( ! isset( $this->thirdPartyActive) ) { |
|
| 52 | + if ( ! isset($this->thirdPartyActive)) { |
|
| 53 | 53 | $this->thirdPartyActive = $this->scopeConfig->getValue(self::XML_PATH_CUSTOMER_PERSONNALIZED_SUGGESTIONS) ? true : false; |
| 54 | 54 | } |
| 55 | 55 | return $this->thirdPartyActive; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | public function getPersonnalizedSuggestionsActive() |
| 63 | 63 | { |
| 64 | - if ( ! isset( $this->personnalizedSuggestionsActive) ) { |
|
| 64 | + if ( ! isset($this->personnalizedSuggestionsActive)) { |
|
| 65 | 65 | $this->personnalizedSuggestionsActive = $this->scopeConfig->getValue(self::XML_PATH_CUSTOMER_THIRD_PARTY) ? true : false; |
| 66 | 66 | } |
| 67 | 67 | return $this->personnalizedSuggestionsActive; |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public function getAccountDeletionActive() |
| 75 | 75 | { |
| 76 | - if ( ! isset( $this->accountDeletionActive) ) { |
|
| 76 | + if ( ! isset($this->accountDeletionActive)) { |
|
| 77 | 77 | $this->accountDeletionActive = $this->scopeConfig->getValue(self::XML_PATH_CUSTOMER_ACCOUNT_DELETION) ? true : false; |
| 78 | 78 | } |
| 79 | 79 | return $this->accountDeletionActive; |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | public function getExportActive() |
| 87 | 87 | { |
| 88 | - if ( ! isset( $this->exportActive) ) { |
|
| 88 | + if ( ! isset($this->exportActive)) { |
|
| 89 | 89 | $this->exportActive = $this->scopeConfig->getValue(self::XML_PATH_CUSTOMER_EXPORT) ? true : false; |
| 90 | 90 | } |
| 91 | 91 | return $this->exportActive; |
@@ -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 { |
@@ -133,8 +133,7 @@ |
||
| 133 | 133 | $clear = openssl_decrypt( $string, self::METHOD, $keyAndIv['key'], 0, $keyAndIv['iv'] ); |
| 134 | 134 | if ( $clear !== false ) { |
| 135 | 135 | $string = $clear; |
| 136 | - } |
|
| 137 | - else { |
|
| 136 | + } else { |
|
| 138 | 137 | break; |
| 139 | 138 | } |
| 140 | 139 | } |
@@ -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); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | { |
| 37 | 37 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); |
| 38 | 38 | $this->cipherHelper = $objectManager->getObject('Adfab\Gdpr\Helper\Cipher'); |
| 39 | - $this->cipherHelper->setKeyAndIv($this->key, base64_decode( $this->initialisationVector ) ); |
|
| 39 | + $this->cipherHelper->setKeyAndIv($this->key, base64_decode($this->initialisationVector)); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function testCrypt() |
| 46 | 46 | { |
| 47 | - $this->assertEquals($this->cryptedMessage, $this->cipherHelper->cipher( $this->clearMessage )); |
|
| 47 | + $this->assertEquals($this->cryptedMessage, $this->cipherHelper->cipher($this->clearMessage)); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -52,6 +52,6 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function testDerypt() |
| 54 | 54 | { |
| 55 | - $this->assertEquals($this->clearMessage, $this->cipherHelper->decipher( $this->cryptedMessage)); |
|
| 55 | + $this->assertEquals($this->clearMessage, $this->cipherHelper->decipher($this->cryptedMessage)); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | \ No newline at end of file |
@@ -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(); |