Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion classes/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function getModelPluginName()
public function getPluginCodeObj()
{
if (!$this->pluginCodeObj) {
throw new SystemException(sprintf('The active plugin is not set in the %s object.', get_class($this)));
throw new SystemException(Lang::get('winter.builder::lang.plugin.error_active_plugin_is_not_set', ['class'=>get_class($this)]));
}

return $this->pluginCodeObj;
Expand Down
4 changes: 2 additions & 2 deletions classes/ComponentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getModelClassDesignTime()
$modelClass = trim(Input::get('modelClass'));

if ($modelClass && !is_scalar($modelClass)) {
throw new ApplicationException('Model class name should be a string.');
throw new ApplicationException(Lang::get('winter.builder::lang.components.error_model_class_name_should_be_a_string'));
}

if (!strlen($modelClass)) {
Expand All @@ -73,7 +73,7 @@ public function getModelClassDesignTime()
}

if (!ModelModel::validateModelClassName($modelClass)) {
throw new ApplicationException('Invalid model class name.');
throw new ApplicationException(Lang::get('winter.builder::lang.components.error_invalid_model_class_name'));
}

return $modelClass;
Expand Down
4 changes: 2 additions & 2 deletions classes/ControllerModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ControllerModel extends BaseModel
public function load($controller)
{
if (!$this->validateFileName($controller)) {
throw new SystemException('Invalid controller file name: '.$language);
throw new SystemException(Lang::get('winter.builder::lang.controller.error_invalid_controller_file_name', ['language'=>$language]));
}

$this->controller = $this->trimExtension($controller);
Expand Down Expand Up @@ -221,7 +221,7 @@ protected function saveController()
}

if (!is_array($this->behaviors)) {
throw new SystemException('The behaviors data should be an array.');
throw new SystemException(Lang::get('winter.builder::lang.controller.error_behaviors_data_should_be_an_array'));
}

$fileContents = File::get($controllerPath);
Expand Down
4 changes: 2 additions & 2 deletions classes/DatabaseTableModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static function tableExists($name)
public function load($name)
{
if (!self::tableExists($name)) {
throw new SystemException(sprintf('The table with name %s doesn\'t exist', $name));
throw new SystemException(Lang::get('winter.builder::lang.database.error_table_with_name_doesnt_exist', ['name'=>$name]));
}

$schema = self::getSchemaManager()->createSchema();
Expand All @@ -90,7 +90,7 @@ public function validate()
$pluginDbPrefix = $this->getPluginCodeObj()->toDatabasePrefix();

if (!strlen($pluginDbPrefix)) {
throw new SystemException('Error saving the table model - the plugin database prefix is not set for the object.');
throw new SystemException(Lang::get('winter.builder::lang.database.error_saving_table_model_plugin_database_prefix_is_not_set_for_object'));
}

$prefix = $pluginDbPrefix.'_';
Expand Down
4 changes: 2 additions & 2 deletions classes/IndexOperationsBehaviorBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class IndexOperationsBehaviorBase extends ControllerBehavior
protected function makeBaseFormWidget($modelCode, $options = [], $aliasSuffix = null)
{
if (!strlen($this->baseFormConfigFile)) {
throw new ApplicationException(sprintf('Base form configuration file is not specified for %s behavior', get_class($this)));
throw new ApplicationException(Lang::get('winter.builder::lang.behavior.error_base_form_configuration_file_is_not_specified', ['class'=>get_class($this)]));
}

$widgetConfig = $this->makeConfig($this->baseFormConfigFile);
Expand All @@ -36,7 +36,7 @@ protected function getPluginCode()
$vector = $this->controller->getBuilderActivePluginVector();

if (!$vector) {
throw new ApplicationException('Cannot determine the currently active plugin.');
throw new ApplicationException(Lang::get('winter.builder::lang.behavior.error_cannot_determine_currently_active_plugin'));
}

return $vector->pluginCodeObj;
Expand Down
2 changes: 1 addition & 1 deletion classes/LanguageMixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function addStringsFromAnotherLanguage($destContents, $srcArray)
$destArray = Yaml::parse($destContents);
}
catch (Exception $ex) {
throw new ApplicationException(sprintf('Cannot parse the YAML content: %s', $ex->getMessage()));
throw new ApplicationException(Lang::get('winter.builder::lang.localization.error_cannot_parse_yaml', ['message'=>$ex->getMessage()]));
}

if (!$destArray) {
Expand Down
10 changes: 5 additions & 5 deletions classes/LocalizationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function save()
public function deleteModel()
{
if ($this->isNewModel()) {
throw new ApplicationException('Cannot delete language file which is not saved yet.');
throw new ApplicationException(Lang::get('winter.builder::lang.localization.error_cannot_delete_lang_file_which_is_not_saved'));
}

$filePath = File::symbolizePath($this->getFilePath());
Expand Down Expand Up @@ -227,7 +227,7 @@ public static function getDefaultLanguage()
$language = Config::get('app.locale');

if (!$language) {
throw new ApplicationException('The default language is not defined in the application configuration (app.locale).');
throw new ApplicationException(Lang::get('winter.builder::lang.localization.error_default_language_is_not_defined'));
}

return $language;
Expand Down Expand Up @@ -329,11 +329,11 @@ protected function getFilePath($language = null)
$language = trim($language);

if (!strlen($language)) {
throw new SystemException('The form model language is not set.');
throw new SystemException(Lang::get('winter.builder::lang.localization.error_form_language_is_not_set'));
}

if (!$this->validateLanguage($language)) {
throw new SystemException('Invalid language file name: '.$language);
throw new SystemException(Lang::get('winter.builder::lang.localization.error_invalid_language_file_name'), ['lang'=>$language]);
}

$path = $this->getPluginCodeObj()->toPluginDirectoryPath().'/lang/'.$language.'/lang.php';
Expand Down Expand Up @@ -364,7 +364,7 @@ protected function modelToLanguageFile()
return "<?php return ".$phpData.";";
}
catch (Exception $ex) {
throw new ApplicationException(sprintf('Cannot parse the YAML content: %s', $ex->getMessage()));
throw new ApplicationException(Lang::get('winter.builder::lang.localization.error_cannot_parse_yaml'), ['message'=>$ex->getMessage()]);
}
}

Expand Down
8 changes: 4 additions & 4 deletions classes/MenusModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function modelToYamlArray()
$mainMenuItem = $this->trimMenuProperties($mainMenuItem);

if (!isset($mainMenuItem['code'])) {
throw new ApplicationException('Cannot save menus - the main menu item code should not be empty.');
throw new ApplicationException(Lang::get('winter.builder::lang.menu.error_main_menu_item_code_should_not_be_empty'));
}

if (isset($mainMenuItem['sideMenu'])) {
Expand All @@ -45,7 +45,7 @@ protected function modelToYamlArray()
$sideMenuItem = $this->trimMenuProperties($sideMenuItem);

if (!isset($sideMenuItem['code'])) {
throw new ApplicationException('Cannot save menus - the side menu item code should not be empty.');
throw new ApplicationException(Lang::get('winter.builder::lang.menu.error_side_menu_item_code_should_not_be_empty'));
}

$code = $sideMenuItem['code'];
Expand Down Expand Up @@ -79,7 +79,7 @@ public function fill(array $attributes)
$attributes['menus'] = json_decode($attributes['menus'], true);

if ($attributes['menus'] === null) {
throw new SystemException('Cannot decode menus JSON string.');
throw new SystemException(Lang::get('winter.builder::lang.menu.error_cannot_decode_menus_json_string'));
}
}

Expand Down Expand Up @@ -141,7 +141,7 @@ protected function trimMenuProperties($menu)
protected function getFilePath()
{
if ($this->pluginCodeObj === null) {
throw new SystemException('Error saving plugin menus model - the plugin code object is not set.');
throw new SystemException(Lang::get('winter.builder::lang.menu.error_plugin_code_object_is_not_set'));
}

return $this->pluginCodeObj->toPluginFilePath();
Expand Down
4 changes: 2 additions & 2 deletions classes/MigrationColumnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static function toDoctrineTypeName($type)
$typeMap = self::getDoctrineTypeMap();

if (!array_key_exists($type, $typeMap)) {
throw new SystemException(sprintf('Unknown column type: %s', $type));
throw new SystemException(Lang::get('winter.builder::lang.migration.error_unknown_column_type', ['type'=>$type]));
}

return $typeMap[$type];
Expand All @@ -104,7 +104,7 @@ public static function toMigrationMethodName($type, $columnName)
$typeMap = self::getDoctrineTypeMap();

if (!in_array($type, $typeMap)) {
throw new SystemException(sprintf('Unknown column type: %s', $type));
throw new SystemException(Lang::get('winter.builder::lang.migration.error_unknown_column_type', ['type'=>$type]));
}

// Some Doctrine types map to multiple migration types, for example
Expand Down
20 changes: 10 additions & 10 deletions classes/MigrationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function getNextVersion()

$versionNumbers = [];
if (!preg_match('/^([0-9]+)\.([0-9]+)\.([0-9]+)$/', $latestVersion, $versionNumbers)) {
throw new SystemException(sprintf('Cannot parse the latest plugin version number: %s.', $latestVersion));
throw new SystemException(Lang::get('winter.builder::lang.migration.error_cannot_parse_latest_plugin_version', ['version'=>$latestVersion]));
}

return $versionNumbers[1].'.'.$versionNumbers[2].'.'.($versionNumbers[3]+1);
Expand Down Expand Up @@ -151,12 +151,12 @@ public function load($versionNumber)
$versionNumber = trim($versionNumber);

if (!strlen($versionNumber)) {
throw new ApplicationException('Cannot load the the version model - the version number should not be empty.');
throw new ApplicationException(Lang::get('winter.builder::lang.migration.error_cannot_load_version_model_should_not_be_empty'));
}

$pluginVersions = $this->getPluginVersionInformation();
if (!array_key_exists($versionNumber, $pluginVersions)) {
throw new ApplicationException('The requested version does not exist in the version information file.');
throw new ApplicationException(Lang::get('winter.builder::lang.migration.error_requested_version_does_not_exist'));
}

$this->version = $versionNumber;
Expand All @@ -171,7 +171,7 @@ public function load($versionNumber)
$cnt = count($versionInformation);

if ($cnt > 2) {
throw new ApplicationException('The requested version cannot be edited with Builder as it refers to multiple PHP scripts.');
throw new ApplicationException(Lang::get('winter.builder::lang.migration.error_requested_version_cannot_be_edited'));
}

if ($cnt > 0) {
Expand All @@ -192,7 +192,7 @@ public function initVersion($versionType)
$versionTypes = ['migration', 'seeder', 'custom'];

if (!in_array($versionType, $versionTypes)) {
throw new SystemException('Unknown version type.');
throw new SystemException(Lang::get('winter.builder::lang.migration.error_unknown_version_type'));
}

$this->version = $this->getNextVersion();
Expand Down Expand Up @@ -340,7 +340,7 @@ protected function saveScriptFile()
$scriptFilePath = $this->getPluginUpdatesPath($this->scriptFileName.'.php');

if (!File::put($scriptFilePath, $this->code)) {
throw new SystemException(sprintf('Error saving file %s', $scriptFilePath));
throw new SystemException(Lang::get('winter.builder::lang.migration.error_saving_file', ['path'=>$scriptFilePath]));
}

@File::chmod($scriptFilePath);
Expand Down Expand Up @@ -373,7 +373,7 @@ protected function loadScriptFile()
$scriptFilePath = $this->getPluginUpdatesPath($this->scriptFileName.'.php');

if (!File::isFile($scriptFilePath)) {
throw new ApplicationException(sprintf('Version file %s is not found.', $scriptFilePath));
throw new ApplicationException(Lang::get('winter.builder::lang.migration.error_version_file_is_not_found', ['path'=>$scriptFilePath]));
}

return File::get($scriptFilePath);
Expand Down Expand Up @@ -424,7 +424,7 @@ protected function insertOrUpdateVersion()

$originalFileContents = File::get($versionFilePath);
if (!$originalFileContents) {
throw new SystemException(sprintf('Error loading file %s', $versionFilePath));
throw new SystemException(Lang::get('winter.builder::lang.migration.error_loading_file', ['path'=>$scriptFilePath]));
}

$versionInformation[$this->version] = [
Expand All @@ -444,7 +444,7 @@ protected function insertOrUpdateVersion()
$yamlData = Yaml::render($versionInformation);

if (!File::put($versionFilePath, $yamlData)) {
throw new SystemException(sprintf('Error saving file %s', $versionFilePath));
throw new SystemException(Lang::get('winter.builder::lang.migration.error_saving_file', ['path'=>$scriptFilePath]));
}

@File::chmod($versionFilePath);
Expand All @@ -467,7 +467,7 @@ protected function deleteVersion()
$yamlData = Yaml::render($versionInformation);

if (!File::put($versionFilePath, $yamlData)) {
throw new SystemException(sprintf('Error saving file %s', $versionFilePath));
throw new SystemException(Lang::get('winter.builder::lang.migration.error_saving_file', ['path'=>$scriptFilePath]));
}

@File::chmod($versionFilePath);
Expand Down
4 changes: 2 additions & 2 deletions classes/ModelFormModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function fill(array $attributes)
$attributes['controls'] = json_decode($attributes['controls'], true);

if ($attributes['controls'] === null) {
throw new SystemException('Cannot decode controls JSON string.');
throw new SystemException(Lang::get('winter.builder::lang.form.error_cannot_decode_controls_json_string'));
}
}

Expand Down Expand Up @@ -64,7 +64,7 @@ public function validate()
parent::validate();

if (!$this->controls) {
throw new ValidationException(['controls' => 'Please create at least one field.']);
throw new ValidationException(['controls' => Lang::get('winter.builder::lang.form.validation_create_at_least_one_field')]);
}
}

Expand Down
6 changes: 3 additions & 3 deletions classes/ModelListModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function fill(array $attributes)
$attributes['columns'] = json_decode($attributes['columns'], true);

if ($attributes['columns'] === null) {
throw new SystemException('Cannot decode columns JSON string.');
throw new SystemException(Lang::get('winter.builder::lang.list.error_cannot_decode_columns_json_string'));
}
}

Expand Down Expand Up @@ -66,7 +66,7 @@ public function validate()
$this->validateDupicateColumns();

if (!$this->columns) {
throw new ValidationException(['columns' => 'Please create at least one column.']);
throw new ValidationException(['columns' => Lang::get('winter.builder::lang.list.validation_columns_create_at_least_one_column')]);
}
}

Expand Down Expand Up @@ -101,7 +101,7 @@ protected function modelToYamlArray()

foreach ($this->columns as $column) {
if (!isset($column['field'])) {
throw new ApplicationException('Cannot save the list - the column field name should not be empty.');
throw new ApplicationException(Lang::get('winter.builder::lang.list.error_name_should_not_be_empty'));
}

$columnName = $column['field'];
Expand Down
4 changes: 2 additions & 2 deletions classes/ModelModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public function getDatabaseTableOptions()
private static function getTableNameFromModelClass($pluginCodeObj, $modelClassName)
{
if (!self::validateModelClassName($modelClassName)) {
throw new SystemException('Invalid model class name: '.$modelClassName);
throw new SystemException(Lang::get('winter.builder::lang.model.error_invalid_model_class_name', ['class'=>$modelClassName]));
}

$modelsDirectoryPath = File::symbolizePath($pluginCodeObj->toPluginDirectoryPath().'/models');
Expand Down Expand Up @@ -198,7 +198,7 @@ public static function getModelColumnsAndTypes($pluginCodeObj, $modelClassName)
$tableName = self::getTableNameFromModelClass($pluginCodeObj, $modelClassName);

if (!DatabaseTableModel::tableExists($tableName)) {
throw new ApplicationException('Database table not found: '.$tableName);
throw new ApplicationException(Lang::get('winter.builder::lang.model.error_db_table_not_found', ['table'=>$tableName]));
}

$schema = DatabaseTableModel::getSchema();
Expand Down
4 changes: 2 additions & 2 deletions classes/ModelYamlModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ protected static function validateModelClassName($modelClassName)
protected function getModelClassName()
{
if ($this->modelClassName === null) {
throw new SystemException('The model class name is not set.');
throw new SystemException(Lang::get('winter.builder::lang.yaml.error_model_class_name_is_not_set'));
}

return $this->modelClassName;
Expand All @@ -184,7 +184,7 @@ protected function getFilePath()
{
$fileName = trim($this->fileName);
if (!strlen($fileName)) {
throw new SystemException('The form model file name is not set.');
throw new SystemException(Lang::get('winter.builder::lang.yaml.error_form_model_file_name_is_not_set'));
}

$fileName = $this->addExtension($fileName);
Expand Down
4 changes: 2 additions & 2 deletions classes/PermissionsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected function modelToYamlArray()
}

if (!isset($permission['permission'])) {
throw new ApplicationException('Cannot save permissions - the permission code should not be empty.');
throw new ApplicationException(Lang::get('winter.builder::lang.permission.error_save_permissions_code_should_not_be_empty'));
}

$code = $permission['permission'];
Expand Down Expand Up @@ -188,7 +188,7 @@ protected function yamlArrayToModel($array)
protected function getFilePath()
{
if ($this->pluginCodeObj === null) {
throw new SystemException('Error saving plugin permission model - the plugin code object is not set.');
throw new SystemException(Lang::get('winter.builder::lang.permission.error_saving_permission_code_is_not_set'));
}

return $this->pluginCodeObj->toPluginFilePath();
Expand Down
4 changes: 2 additions & 2 deletions classes/PhpSourceStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function restoreBookmark()
{
$head = array_pop($this->headBookmarks);
if ($head === null) {
throw new SystemException("Can't restore PHP token stream bookmark - the bookmark doesn't exist");
throw new SystemException(Lang::get('winter.builder::lang.stream.error_cant_restore_token_stream_bookmark'));
}

return $this->setHead($head);
Expand All @@ -81,7 +81,7 @@ public function discardBookmark()
{
$head = array_pop($this->headBookmarks);
if ($head === null) {
throw new SystemException("Can't discard PHP token stream bookmark - the bookmark doesn't exist");
throw new SystemException(Lang::get('winter.builder::lang.stream.error_cant_discard_token_stream_bookmark'));
}
}

Expand Down
Loading