Exemplo n.º 1
0
 public function set($config, $value = null)
 {
     if (empty($this->config)) {
         $this->get();
     }
     if (is_array($config)) {
         foreach ($config as $key => $value) {
             $this->set_val($this->config, explode('.', $key), $value);
         }
     } else {
         $this->set_val($this->config, explode('.', $config), $value);
     }
     $this->config['modules_path'] = $this->config['folder'];
     if (!array_key_exists('namespace', $this->config) || is_null($this->config['namespace'])) {
         $this->config['namespace'] = ucfirst($this->config['appname']) . '\\Modules';
     }
     $content = json_encode($this->config);
     $prettifier = new JsonPrettyPrinter();
     $content = $prettifier->format($content);
     $content = str_replace('\\/', '/', $content);
     file_put_contents($this->file, $content);
 }
                    throw new \Exception("Composer URL '{$url}' is not valid.");
                }
                $data['repositories'][] = array('type' => 'composer', 'url' => $url);
            }
        }
    }
    if ($options['minimum-stability'] || empty($data['minimum-stability'])) {
        $data['minimum-stability'] = (string) $options['minimum-stability'] ?: 'stable';
    }
    if (isset($options['prefer-stable'])) {
        $data['prefer-stable'] = getBoolean($options['prefer-stable']);
    }
    $data['extra']['magento-force'] = getBoolean($options['magento-force']);
    $data['extra']['magento-deploystrategy'] = (string) $options['magento-deploystrategy'] ?: 'symlink';
    if ($options['magento-root-dir']) {
        $data['extra']['magento-root-dir'] = $options['magento-root-dir'];
    }
    /**
     * Ignore updating Varien_Autoload class because the issue
     * @link https://github.com/ajbonner/magento-composer-autoload/issues/4
     */
    if (!isset($data['extra']['magento-deploystrategy-overwrite'])) {
        $data['extra']['magento-deploystrategy-overwrite']['ajbonner/magento-composer-autoload'] = 'none';
    }
    //write json
    $composerJson = json_encode($data);
    $formatter = new JsonPrettyPrinter();
    echo $formatter->format($composerJson);
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage() . PHP_EOL;
}
Exemplo n.º 3
0
 public function updateComposer($previous = null)
 {
     $composer_file = base_path() . '/composer.json';
     if (is_readable($composer_file)) {
         $composer_content = file_get_contents($composer_file);
         $composer_content = json_decode($composer_content, true);
         if (!in_array($this->config->get('folder'), $composer_content['autoload']['classmap'])) {
             $composer_content['autoload']['classmap'][] = $this->config->get('folder');
             $composer_content = json_encode($composer_content);
             $prettifier = new JsonPrettyPrinter();
             $composer_content = $prettifier->format($composer_content);
             $composer_content = str_replace('\\/', '/', $composer_content);
             file_put_contents($composer_file, $composer_content);
             $this->info('Modules folder added into composer.json');
         } else {
             $this->info('Modules folder already in composer.json');
         }
     }
     $output = array();
     exec('composer dump-autoload', $output);
     foreach ($output as $line) {
         echo $line . PHP_EOL;
     }
 }