Version 0.2.0: Mysterious Bobsled For Kids
Pre-release
Pre-release
Major Features
Editing Files
A new editFile method was added to the Editor class. This method makes it slightly easier to instantiate an editor using Symfony's Process component. The process is created and run synchronously and the Process element is returned. For example:
use Nubs\Sensible\Editor;
use Symfony\Component\Process\ProcessBuilder;
$editor = new Editor();
$process = $editor->editFile(new ProcessBuilder(), '/path/to/a/file');
if ($process->isSuccessful()) {
// Process changes to file?
} else {
// Editor exited with a non-zero status - user canceled editing?
}Editing Data
As a wrapper to editFile, a new editData method was also added that handles editing a string using a temporary file (located in sys_get_temp_dir()) as an intermediary. The modified string will be returned. If the editor exits with a non-zero status, the modifications are discarded and the original string is returned unchanged.
` element is returned. For example:
use Nubs\Sensible\Editor;
use Symfony\Component\Process\ProcessBuilder;
$editor = new Editor();
$data = $editor->editData(new ProcessBuilder(), 'The text to edit here');
// Continue using the modified $data