lithium\console\command\g11n\Extract::_writeTemplate PHP Method

_writeTemplate() protected method

Prompts for data source and writes template.
protected _writeTemplate ( array $data ) : boolean | void
$data array Data to save.
return boolean | void Return `false` if writing the catalog failed.
    protected function _writeTemplate($data)
    {
        $message = array();
        $message[] = 'In order to proceed you need to choose a `Catalog` configuration';
        $message[] = 'which is used for writing the template. The adapter for the configuration';
        $message[] = 'should be capable of handling write requests for the `messageTemplate`';
        $message[] = 'category.';
        $this->out($message);
        $this->out();
        $name = $this->_configuration(array('adapter' => 'Gettext', 'path' => $this->destination, 'scope' => $this->scope));
        if ($name != 'temporary') {
            $scope = $this->in('Scope:', array('default' => $this->scope));
        }
        $message = array();
        $message[] = 'The template is now ready to be saved.';
        $message[] = 'Please note that an existing template will be overwritten.';
        $this->out($message);
        $this->out();
        if ($this->in('Save?', array('choices' => array('y', 'n'), 'default' => 'y')) != 'y') {
            $this->out('Aborting upon user request.');
            $this->stop(1);
        }
        try {
            return Catalog::write($name, 'messageTemplate', 'root', $data, compact('scope'));
        } catch (Exception $e) {
            return false;
        }
    }