-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1580 from magento-engcom/2.2-develop-prs
- Loading branch information
Showing
8 changed files
with
372 additions
and
81 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
lib/internal/Magento/Framework/Config/Data/ConfigDataFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Framework\Config\Data; | ||
|
||
use Magento\Framework\App\ObjectManager; | ||
use Magento\Framework\ObjectManagerInterface; | ||
|
||
/** | ||
* Factory for ConfigData | ||
*/ | ||
class ConfigDataFactory | ||
{ | ||
/** | ||
* @var ObjectManager | ||
*/ | ||
private $objectManager; | ||
|
||
/** | ||
* Factory constructor | ||
* | ||
* @param ObjectManagerInterface $objectManager | ||
*/ | ||
public function __construct(ObjectManagerInterface $objectManager) | ||
{ | ||
$this->objectManager = $objectManager; | ||
} | ||
|
||
/** | ||
* Returns a new instance of ConfigData on every call. | ||
* | ||
* @param string $fileKey | ||
* @return ConfigData | ||
*/ | ||
public function create($fileKey) | ||
{ | ||
return $this->objectManager->create(ConfigData::class, ['fileKey' => $fileKey]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Setup\Model; | ||
|
||
use Magento\Framework\Config\ConfigOptionsListConstants; | ||
use Magento\Framework\Math\Random; | ||
|
||
/** | ||
* Generates a crypt | ||
*/ | ||
class CryptKeyGenerator implements CryptKeyGeneratorInterface | ||
{ | ||
/** | ||
* @var Random | ||
*/ | ||
private $random; | ||
|
||
/** | ||
* CryptKeyGenerator constructor. | ||
* | ||
* @param Random $random | ||
*/ | ||
public function __construct(Random $random) | ||
{ | ||
$this->random = $random; | ||
} | ||
|
||
/** | ||
* Generates & returns a string to be used as crypt key. | ||
* | ||
* The key length is not a parameter, but an implementation detail. | ||
* | ||
* @return string | ||
* | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
*/ | ||
public function generate() | ||
{ | ||
return md5($this->getRandomString()); | ||
} | ||
|
||
/** | ||
* Returns a random string. | ||
* | ||
* @return string | ||
*/ | ||
private function getRandomString() | ||
{ | ||
return $this->random->getRandomString(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
setup/src/Magento/Setup/Model/CryptKeyGeneratorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Setup\Model; | ||
|
||
/** | ||
* Interface for crypt key generators. | ||
*/ | ||
interface CryptKeyGeneratorInterface | ||
{ | ||
/** | ||
* Generates & returns a string to be used as crypt key. | ||
* | ||
* The key length is not a parameter, but an implementation detail. | ||
* | ||
* @return string | ||
*/ | ||
public function generate(); | ||
} |
Oops, something went wrong.