コード例 #1
0
ファイル: DebugCommand.php プロジェクト: Maksold/platform
 /**
  * @param OutputInterface $output
  * @param ConfigInterface $config
  * @param string|null     $attrName
  */
 protected function dumpConfig(OutputInterface $output, ConfigInterface $config, $attrName = null)
 {
     $data = $config->all();
     $res = [$config->getId()->getScope() => $data];
     if (!empty($attrName) && (isset($data[$attrName]) || array_key_exists($attrName, $data))) {
         $res = [$config->getId()->getScope() => [$attrName => $data[$attrName]]];
     }
     $output->writeln(print_r($res, true));
 }
コード例 #2
0
 /**
  * @param ConfigInterface $config
  * @SuppressWarnings(PHPMD)
  */
 public function calculateConfigChangeSet(ConfigInterface $config)
 {
     $originConfigValue = array();
     if ($this->originalConfigs->containsKey($config->getId()->toString())) {
         $originConfig = $this->originalConfigs->get($config->getId()->toString());
         $originConfigValue = $originConfig->all();
     }
     foreach ($config->all() as $key => $value) {
         if (!isset($originConfigValue[$key])) {
             $originConfigValue[$key] = null;
         }
     }
     $diffNew = array_udiff_assoc($config->all(), $originConfigValue, function ($a, $b) {
         return $a == $b ? 0 : 1;
     });
     $diffOld = array_udiff_assoc($originConfigValue, $config->all(), function ($a, $b) {
         return $a == $b ? 0 : 1;
     });
     $diff = array();
     foreach ($diffNew as $key => $value) {
         $oldValue = isset($diffOld[$key]) ? $diffOld[$key] : null;
         $diff[$key] = array($oldValue, $value);
     }
     if (!$this->configChangeSets->containsKey($config->getId()->toString())) {
         $this->configChangeSets->set($config->getId()->toString(), array());
     }
     if (count($diff)) {
         $changeSet = array_merge($this->configChangeSets->get($config->getId()->toString()), $diff);
         $this->configChangeSets->set($config->getId()->toString(), $changeSet);
     }
 }
コード例 #3
0
ファイル: ConfigManager.php プロジェクト: nmallare/platform
 /**
  * In case of FieldConfigId replaces OLD field name with given NEW one
  *
  * @param ConfigInterface $config
  * @param $newFieldName
  * @return Config|ConfigInterface
  */
 protected function changeConfigFieldName(ConfigInterface $config, $newFieldName)
 {
     $configId = $config->getId();
     if ($configId instanceof FieldConfigId) {
         $newConfigId = new FieldConfigId($configId->getScope(), $configId->getClassName(), $newFieldName, $configId->getFieldType());
         $newConfig = new Config($newConfigId);
         $newConfig->setValues($config->all());
         $config = $newConfig;
     }
     return $config;
 }
コード例 #4
0
 /**
  * @param ConfigInterface $config
  * @SuppressWarnings(PHPMD)
  */
 public function calculateConfigChangeSet(ConfigInterface $config)
 {
     $configKey = $this->buildConfigKey($config->getId());
     $originConfigValues = isset($this->originalConfigs[$configKey]) ? $this->originalConfigs[$configKey]->all() : [];
     $configValues = $config->all();
     foreach ($configValues as $key => $value) {
         if (!isset($originConfigValues[$key])) {
             $originConfigValues[$key] = null;
         }
     }
     $diffNew = array_udiff_assoc($configValues, $originConfigValues, function ($a, $b) {
         return $a == $b ? 0 : 1;
     });
     $diffOld = array_udiff_assoc($originConfigValues, $configValues, function ($a, $b) {
         return $a == $b ? 0 : 1;
     });
     $diff = [];
     foreach ($diffNew as $key => $value) {
         $oldValue = isset($diffOld[$key]) ? $diffOld[$key] : null;
         $diff[$key] = [$oldValue, $value];
     }
     if (!empty($diff)) {
         $this->configChangeSets[$configKey] = isset($this->configChangeSets[$configKey]) ? array_merge($this->configChangeSets[$configKey], $diff) : $diff;
     } elseif (!isset($this->configChangeSets[$configKey])) {
         $this->configChangeSets[$configKey] = [];
     }
 }