コード例 #1
0
 /**
  * Regenerate salts for the environment file.
  *
  * [--file=<path-to-dotenv>]
  * : Path to the environment file.  Default: '.env'
  *
  * @when before_wp_load
  *
  * @param $_
  * @param $assoc_args
  */
 public function regenerate($_, $assoc_args)
 {
     $this->init_args(func_get_args());
     $this->update_salts(true);
     if (!$this->env->save()) {
         WP_CLI::error('Failed to update salts.');
     }
     WP_CLI::success('Salts regenerated.');
 }
コード例 #2
0
 /**
  * @test
  */
 public function it_does_not_write_to_the_file_until_save_is_called()
 {
     $path = $this->copy_fixture('env-basic');
     $env = new File($path);
     $env->load();
     $this->assertNull($env->get('SOME_KEY'));
     $env->set('SOME_KEY', 'totally set');
     $this->assertSame('totally set', $env->get('SOME_KEY'));
     $this->assertSame('integer', gettype($env->save()));
     $env->set('SOME_KEY', 'this will be wiped out once we load in a second');
     // refresh the instance from the file
     $env->load();
     $this->assertSame('totally set', $env->get('SOME_KEY'));
 }
コード例 #3
0
 /**
  * Iterate over each line and prompt for a new value
  *
  * @param File $env
  *
  * @return int
  */
 protected function prompt_all(File $env)
 {
     $env->dictionary()->each(function ($value, $key) use($env) {
         $env->set($key, $this->prompt($key, $value));
     });
     $env->save();
 }