34 private $configHashGenerator;
41 private $dataConfigCollector;
48 private $flagResource;
64 Hash\Generator $configHashGenerator,
69 $this->configHashGenerator = $configHashGenerator;
70 $this->dataConfigCollector = $dataConfigCollector;
71 $this->flagResource = $flagResource;
72 $this->flagFactory = $flagFactory;
86 public function regenerate($sectionName =
null)
89 $hashes = $this->
get();
90 $configs = $this->dataConfigCollector->getConfig($sectionName);
92 foreach ($configs as $section =>
$config) {
93 $hashes[$section] = $this->configHashGenerator->generate(
$config);
97 $flag = $this->getFlagObject();
98 $flag->setFlagData($hashes);
99 $this->flagResource->save($flag);
100 }
catch (\Exception $exception) {
101 throw new LocalizedException(
__(
"The hash isn't saved."), $exception);
110 public function get()
113 $flag = $this->getFlagObject();
114 return (array) ($flag->getFlagData() ?: []);
124 private function getFlagObject()
127 $flag = $this->flagFactory
128 ->create([
'data' => [
'flag_code' => self::CONFIG_KEY]]);
129 $this->flagResource->load($flag, self::CONFIG_KEY,
'flag_code');
__construct(Hash\Generator $configHashGenerator, DataCollector $dataConfigCollector, FlagResource $flagResource, FlagFactory $flagFactory)