本文整理匯總了PHP中Magento\Framework\Encryption\EncryptorInterface::hash方法的典型用法代碼示例。如果您正苦於以下問題:PHP EncryptorInterface::hash方法的具體用法?PHP EncryptorInterface::hash怎麽用?PHP EncryptorInterface::hash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\Encryption\EncryptorInterface
的用法示例。
在下文中一共展示了EncryptorInterface::hash方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: install
/**
* {@inheritdoc}
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
/** @var State[] $stateIndexers */
$stateIndexers = [];
$states = $this->statesFactory->create();
foreach ($states->getItems() as $state) {
/** @var State $state */
$stateIndexers[$state->getIndexerId()] = $state;
}
foreach ($this->config->getIndexers() as $indexerId => $indexerConfig) {
$expectedHashConfig = $this->encryptor->hash($this->encoder->encode($indexerConfig), Encryptor::HASH_VERSION_MD5);
if (isset($stateIndexers[$indexerId])) {
if ($stateIndexers[$indexerId]->getHashConfig() != $expectedHashConfig) {
$stateIndexers[$indexerId]->setStatus(StateInterface::STATUS_INVALID);
$stateIndexers[$indexerId]->setHashConfig($expectedHashConfig);
$stateIndexers[$indexerId]->save();
}
} else {
/** @var State $state */
$state = $this->stateFactory->create();
$state->loadByIndexer($indexerId);
$state->setHashConfig($expectedHashConfig);
$state->setStatus(StateInterface::STATUS_INVALID);
$state->save();
}
}
}