lithium\console\command\Library::config PHP Method

config() public method

Add configuration and write data in json format.
public config ( string $key = null, string $value = null, string $options = true ) : void
$key string (server)
$value string value of key
$options string [optional]
return void
    public function config($key = null, $value = null, $options = true)
    {
        if (empty($key) || empty($value)) {
            return $this->_settings;
        }
        switch ($key) {
            case 'server':
                $this->_settings['servers'][$value] = $options;
                break;
        }
        return file_put_contents($this->conf, json_encode($this->_settings));
    }

Usage Example

Example #1
0
 public function testFindNotFound()
 {
     $this->request->params += array('server' => null);
     $library = new Library(array('request' => $this->request, 'classes' => $this->classes));
     $library->conf = $this->testConf;
     $library->config('server', 'localhost');
     $library->find();
     $expected = "No plugins at localhost\n";
     $result = $library->response->output;
     $this->assertEqual($expected, $result);
 }