lithium\console\command\g11n\Extract::_writeTemplate()

protected method

Prompts for data source and writes template.

Parameters

  • array $data

    Data to save.

Returns

boolean|void

Return false if writing the catalog failed.

Source

	protected function _writeTemplate($data) {
		$message = [];

		$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([
			'adapter' => 'Gettext',
			'path' => $this->destination,
			'scope' => $this->scope
		]);

		if ($name != 'temporary') {
			$scope = $this->in('Scope:', ['default' => $this->scope]);
		}

		$message = [];
		$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?', ['choices' => ['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;
		}
	}