public function testWriteAndRead()
 {
     $config = new Config(array('default' => array('test' => 'foo')));
     $this->writer->toFile($this->getTestAssetFileName(), $config);
     $config = $this->reader->fromFile($this->getTestAssetFileName());
     $this->assertEquals('foo', $config['default']['test']);
 }
Example #2
0
    /**
     * Delete a key from the configuration array
     *
     * $key may be either an array of keys or a dot-separated set of keys.
     *
     * @param  array|string $keys
     * @return array
     */
    public function deleteKey($keys)
    {
        // Get local config file
        $config = array();
        if (file_exists($this->fileName)) {
            $config = include $this->fileName;
            if (!is_array($config)) {
                $config = array();
            }
        }

        if (!is_array($keys)) {
            $keys = explode('.', $keys);
        }

        if (empty($keys)) {
            return $config;
        }

        $this->deleteByKey($config, $keys);
        $this->writer->toFile($this->fileName, $config);
        $this->invalidateCache($this->fileName);

        // Reseed configuration
        $this->config = $config;

        return $config;
    }
Example #3
0
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $this->questionHelper = $this->getHelper('question');
     $this->processHelper = $this->getHelper('process');
     $params = [];
     $output->writeln(['<info>Welcome to Shlink!!</info>', 'This process will guide you through the installation.']);
     // Check if a cached config file exists and drop it if so
     if (file_exists('data/cache/app_config.php')) {
         $output->write('Deleting old cached config...');
         if (unlink('data/cache/app_config.php')) {
             $output->writeln(' <info>Success</info>');
         } else {
             $output->writeln(' <error>Failed!</error> You will have to manually delete the data/cache/app_config.php file to get' . ' new config applied.');
         }
     }
     // Ask for custom config params
     $params['DATABASE'] = $this->askDatabase();
     $params['URL_SHORTENER'] = $this->askUrlShortener();
     $params['LANGUAGE'] = $this->askLanguage();
     $params['APP'] = $this->askApplication();
     // Generate config params files
     $config = $this->buildAppConfig($params);
     $this->configWriter->toFile('config/params/generated_config.php', $config, false);
     $output->writeln(['<info>Custom configuration properly generated!</info>', '']);
     // Generate database
     if (!$this->createDatabase()) {
         return;
     }
     // Run database migrations
     $output->writeln('Updating database...');
     if (!$this->runCommand('php vendor/bin/doctrine-migrations migrations:migrate', 'Error updating database.')) {
         return;
     }
     // Generate proxies
     $output->writeln('Generating proxies...');
     if (!$this->runCommand('php vendor/bin/doctrine.php orm:generate-proxies', 'Error generating proxies.')) {
         return;
     }
 }