/** * {@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(); } } }