Method addTranslation
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addTranslation(App\Request $request)
{
$moduleName = $request->getModule(false);
try {
$langs = $request->getArray('langs', 1);
Function addTranslation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function addTranslation(App\Request $request)
{
$moduleName = $request->getModule(false);
try {
$langs = $request->getArray('langs', 1);
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Missing class import via use statement (line '39', column '15'). Open
throw new \App\Exceptions\Security('ERR_LANGUAGE_DOES_NOT_EXIST');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '77', column '15'). Open
throw new \App\Exceptions\Security('ERR_LANGUAGE_DOES_NOT_EXIST');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '103', column '15'). Open
throw new \App\Exceptions\Security('ERR_LANGUAGE_DOES_NOT_EXIST');
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '133', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '42', column '15'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '87', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '60', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '80', column '15'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '115', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '106', column '15'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '171', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '154', column '19'). Open
$response = new Vtiger_Response();
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '151', column '14'). Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method addTranslation uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$result = ['success' => false, 'message' => \App\Language::translate('LBL_KeyExists', $moduleName)];
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method delete uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$response->setResult(['success' => false]);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method setAsDefault uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$response->setResult(['success' => false]);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Avoid using static access to class 'Settings_LangManagement_Module_Model' in method 'setAsDefault'. Open
$saveResp = Settings_LangManagement_Module_Model::setAsDefault($request->getByType('prefix'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'setAsDefault'. Open
$response->setResult(['success' => true, 'message' => \App\Language::translate('LBL_SaveDataOK', $request->getModule(false)), 'prefixOld' => $saveResp['prefixOld']]);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'addTranslation'. Open
$result = ['success' => false, 'message' => \App\Language::translate('LBL_KeyExists', $moduleName)];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Settings_LangManagement_Module_Model' in method 'add'. Open
$saveResp = Settings_LangManagement_Module_Model::add($params);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'add'. Open
'message' => \App\Language::translate($saveResp['data'], $request->getModule(false)),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Language' in method 'saveTranslation'. Open
}
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'addTranslation'. Open
\App\Language::translationModify($lang, $mod, $type, $variable, $request->getForHtml($lang));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'saveTranslation'. Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_UpdateTranslationOK', $moduleName)];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'deleteTranslation'. Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_DeleteTranslationOK', $moduleName)];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Settings_LangManagement_Module_Model' in method 'addTranslation'. Open
$moduleModel = Settings_LangManagement_Module_Model::getInstance($moduleName);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Language' in method 'addTranslation'. Open
if (!$langs || array_diff($langs, array_keys(App\Language::getAll()))) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'Settings_LangManagement_Module_Model' in method 'delete'. Open
$saveResp = Settings_LangManagement_Module_Model::delete($lang);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'saveTranslation'. Open
\App\Language::translationModify($request->getByType('lang'), $request->getByType('mod'), $request->getByType('type'), $request->getByType('variable', 'Text'), $request->getForHtml('val'));
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'delete'. Open
$response->setResult(['success' => true, 'message' => \App\Language::translate('LBL_DeleteDataOK', $request->getModule(false))]);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'addTranslation'. Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_AddTranslationOK', $moduleName)];
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class 'App\Language' in method 'deleteTranslation'. Open
if (!$langs || array_diff($langs, array_keys(App\Language::getAll()))) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'deleteTranslation'. Open
\App\Language::translationModify($lang, $request->getByType('mod'), $request->getByType('type'), $request->getByType('langkey', 'Text'), '', true);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Config' in method 'delete'. Open
if (\in_array($lang, [\App\Config::main('default_language'), \App\Language::DEFAULT_LANG])) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Define a constant instead of duplicating this literal "success" 14 times. Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_AddTranslationOK', $moduleName)];
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "prefix" 4 times. Open
'prefix' => $request->getByType('prefix', 'Text'),
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "message" 7 times. Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_AddTranslationOK', $moduleName)];
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "ERR_NOT_ALLOWED_VALUE" 4 times. Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "ERR_LANGUAGE_DOES_NOT_EXIST" 3 times. Open
throw new \App\Exceptions\Security('ERR_LANGUAGE_DOES_NOT_EXIST');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Settings_LangManagement_SaveAjax_Action extends Settings_Vtiger_IndexAjax_View
- Exclude checks
The class Settings_LangManagement_SaveAjax_Action is not named in CamelCase. Open
class Settings_LangManagement_SaveAjax_Action extends Settings_Vtiger_IndexAjax_View
{
/**
* Constructor.
*/
- Read upRead up
- Exclude checks
CamelCaseClassName
Since: 0.2
It is considered best practice to use the CamelCase notation to name classes.
Example
class class_name {
}
Source
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($request->getByType('type'), \App\Language::LANG_TYPE)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$data = $moduleModel->loadLangTranslation($langs, $mod);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 201 characters Open
\App\Language::translationModify($request->getByType('lang'), $request->getByType('mod'), $request->getByType('type'), $request->getByType('variable', 'Text'), $request->getForHtml('val'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\Security('ERR_LANGUAGE_DOES_NOT_EXIST');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = ['success' => false];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('addTranslation');
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_AddTranslationOK', $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult($result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Save translations.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'prefix' => $request->getByType('prefix', 'Text'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lang = $request->getByType('prefix');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult(['success' => true, 'message' => \App\Language::translate('LBL_DeleteDataOK', $request->getModule(false))]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$variable = $request->getByType('variable', 'Text');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = Settings_LangManagement_Module_Model::getInstance($moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset(App\Language::getAll()[$request->getByType('lang')])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$langs || array_diff($langs, array_keys(App\Language::getAll()))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($request->getByType('type'), \App\Language::LANG_TYPE)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$langs || array_diff($langs, array_keys(App\Language::getAll()))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\Security
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($langs as $lang) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Language::translationModify($lang, $request->getByType('mod'), $request->getByType('type'), $request->getByType('langkey', 'Text'), '', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Language::translationModify($lang, $mod, $type, $variable, $request->getForHtml($lang));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = ['success' => false];
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_UpdateTranslationOK', $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\Exception $ex) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => $request->getByType('label', 'Text'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langs = $request->getArray('lang', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 178 characters Open
$response->setResult(['success' => true, 'message' => \App\Language::translate('LBL_SaveDataOK', $request->getModule(false)), 'prefixOld' => $saveResp['prefixOld']]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('deleteTranslation');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function addTranslation(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_UpdateTranslationOK', $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function deleteTranslation(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'success' => $saveResp['success'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult(['success' => false]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mod = $request->getByType('mod');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_AddTranslationOK', $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult($result);
- Exclude checks
Line exceeds 120 characters; contains 163 characters Open
\App\Language::translationModify($lang, $request->getByType('mod'), $request->getByType('type'), $request->getByType('langkey', 'Text'), '', true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult(['success' => true, 'message' => \App\Language::translate('LBL_SaveDataOK', $request->getModule(false)), 'prefixOld' => $saveResp['prefixOld']]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Constructor.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('saveTranslation');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\Security('ERR_LANGUAGE_DOES_NOT_EXIST');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Language::translationModify($request->getByType('lang'), $request->getByType('mod'), $request->getByType('type'), $request->getByType('variable', 'Text'), $request->getForHtml('val'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($saveResp) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('delete');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langs = $request->getArray('langs', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function saveTranslation(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\Security('ERR_LANGUAGE_DOES_NOT_EXIST');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_DeleteTranslationOK', $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('setAsDefault');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = ['success' => false, 'message' => \App\Language::translate('LBL_KeyExists', $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Add translation.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\Security
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Remove translation.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $request->getModule(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult($result);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function delete(App\Request $request)
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
$response->setResult(['success' => true, 'message' => \App\Language::translate('LBL_DeleteDataOK', $request->getModule(false))]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($saveResp['success']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
parent::__construct();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('save');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\Exception $ex) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$type = $request->getByType('type');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = ['success' => false];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($data[$type][$variable])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function add(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'name' => $request->getByType('name', 'Text'),
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$result = ['success' => true, 'message' => \App\Language::translate('LBL_DeleteTranslationOK', $moduleName)];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$saveResp = Settings_LangManagement_Module_Model::add($params);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'message' => \App\Language::translate($saveResp['data'], $request->getModule(false)),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function __construct()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->exposeMethod('add');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($langs as $lang) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param \App\Request $request
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\Exception $ex) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!\in_array($request->getByType('type'), \App\Language::LANG_TYPE)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->emit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$params = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Delete language.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\IllegalValue('ERR_NOT_ALLOWED_VALUE', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$saveResp = Settings_LangManagement_Module_Model::delete($lang);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array($lang, [\App\Config::main('default_language'), \App\Language::DEFAULT_LANG])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'params' => $params
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function setAsDefault(App\Request $request)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function added new language.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to set language as default.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$saveResp = Settings_LangManagement_Module_Model::setAsDefault($request->getByType('prefix'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = new Vtiger_Response();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response->setResult(['success' => false]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Class name "Settings_LangManagement_SaveAjax_Action" is not in camel caps format Open
class Settings_LangManagement_SaveAjax_Action extends Settings_Vtiger_IndexAjax_View
- Exclude checks