MageConfigSync\ConfigYaml::build PHP Méthode

build() public static méthode

public static build ( ConfigurationAdapter $config_adapter, boolean $environment = false ) : ConfigYaml
$config_adapter MageConfigSync\Magento\ConfigurationAdapter
$environment boolean
Résultat ConfigYaml
    public static function build(ConfigurationAdapter $config_adapter, $environment = false)
    {
        $data_structure = array();
        foreach ($config_adapter->getAllValues() as $row) {
            $scope = $row['scope'];
            $scope_id = $row['scope_id'];
            $path = $row['path'];
            $value = $row['value'];
            $scope_key = self::buildScopeKey($scope, $scope_id);
            if (!isset($data_structure[$scope_key])) {
                $data_structure[$scope_key] = array();
            }
            $data_structure[$scope_key][$path] = $value;
        }
        return new ConfigYaml($data_structure, $environment);
    }

Usage Example

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $magento = new Magento($input->getOption('magento-root'));
     $config_adapter = new ConfigurationAdapter($magento);
     $yaml = new Parser();
     if ($input->getArgument('config-yaml-file')) {
         $config_yaml_file = $input->getArgument('config-yaml-file');
         if (!file_exists($config_yaml_file)) {
             throw new \Exception("File ({$config_yaml_file}) does not exist");
         }
         if (!is_readable($config_yaml_file)) {
             throw new \Exception("File ({$config_yaml_file}) is not readable");
         }
         $config_db_yaml = ConfigYaml::build($config_adapter);
         $config_file_contents = $yaml->parse(file_get_contents($config_yaml_file));
         $config_file_yaml = new ConfigYaml($config_file_contents, $input->getOption('env'));
         $diff = ConfigYaml::compare($config_file_yaml, $config_db_yaml);
         if (count($diff) > 0) {
             $db_data = $config_db_yaml->getData();
             $file_data = $config_file_yaml->getData();
             $diff_count = 0;
             foreach ($diff as $scope => $scope_data) {
                 foreach ($scope_data as $key => $value) {
                     $diff_count++;
                     $diff_message = sprintf("%s/%s is different (File: %s, DB: %s)", $scope, $key, $this->decorateValue($file_data[$scope][$key]), $this->decorateValue($db_data[$scope][$key]));
                     $output->writeln($diff_message);
                 }
             }
             return $diff_count;
         } else {
             return 0;
         }
     }
 }
All Usage Examples Of MageConfigSync\ConfigYaml::build