Method getTreeList
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getTreeList()
{
$trees = [];
$isDeletable = $this->getRelationModel()->privilegeToTreeDelete();
$lastId = 0;
Method getRecords
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function getRecords()
{
$selectedRecords = $this->getSelectedRecords();
$isDeletable = $this->isDeletable();
if (2 == $this->getRelationType()) {
Function getTreeList
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
private function getTreeList()
{
$trees = [];
$isDeletable = $this->getRelationModel()->privilegeToTreeDelete();
$lastId = 0;
- 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
Function getRecords
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function getRecords()
{
$selectedRecords = $this->getSelectedRecords();
$isDeletable = $this->isDeletable();
if (2 == $this->getRelationType()) {
- 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 '47', column '21'). Open
$fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();
- 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 '128', column '22'). Open
$dataReader = (new App\Db\Query())
- 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 '172', column '15'). Open
return (new App\Db\Query())->select(['tree'])->from('u_#__crmentity_rel_tree')
- 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 getSelectedRecords has a boolean flag argument $onlyKeys, which is a certain sign of a Single Responsibility Principle violation. Open
private function getSelectedRecords($onlyKeys = true)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
Avoid using static access to class '\App\Language' in method 'getTreeList'. Open
'text' => \App\Language::translate($row['name'], $this->getModuleName()),
- 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 'Vtiger_Relation_Model' in method 'getRelationModel'. Open
$this->relationModel = Vtiger_Relation_Model::getInstance($srcModuleModel, $this->get('module'));
- 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
The method getRecords uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$listEntries = $this->getSelectedRecords(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 'Vtiger_Record_Model' in method 'getSelectedRecords'. Open
$parentRecordModel = Vtiger_Record_Model::getInstanceById($this->get('srcRecord'), $this->get('srcModule'));
- 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 'Vtiger_Loader' in method 'getInstance'. Open
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'TreeCategoryModal', $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\Module' in method 'getTreeField'. Open
$fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();
- 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 'Vtiger_RelationListView_Model' in method 'getSelectedRecords'. Open
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $this->getModuleName());
- 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 'Vtiger_ListView_Model' in method 'getAllRecords'. Open
$listViewModel = Vtiger_ListView_Model::getInstanceForPopup($this->getModuleName(), $this->get('srcModule'));
- 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 'Vtiger_Module_Model' in method 'getRelationModel'. Open
$srcModuleModel = Vtiger_Module_Model::getInstance($this->get('srcModule'));
- 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 "fieldTemp" 3 times. Open
if ($this->has('fieldTemp')) {
- 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 "relationType" 4 times. Open
if ($this->has('relationType')) {
- 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 "category" 4 times. Open
'type' => 'category',
- 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 "fieldname" 3 times. Open
$fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();
- 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 "srcModule" 5 times. Open
$srcModuleModel = Vtiger_Module_Model::getInstance($this->get('srcModule'));
- 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 "module" 3 times. Open
$instance->set('module', $moduleModel)->set('moduleName', $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 "srcRecord" 3 times. Open
->where(['crmid' => $this->get('srcRecord'), 'relmodule' => $this->get('module')->getId()])
- 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.
Call to undeclared method \App\Db\Query::from
Open
$dataReader = (new App\Db\Query())
- Exclude checks
Call to method setField
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$listViewModel->getQueryGenerator()->setField($this->getTreeField()['fieldname']);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();
- Exclude checks
Return type of getTemplate()
is undeclared type \type
Open
public function getTemplate()
- Exclude checks
Reference to undeclared property \Vtiger_TreeCategoryModal_Model->lastIdinTree
Open
'id' => $this->lastIdinTree,
- Exclude checks
Reference to undeclared property \Vtiger_TreeCategoryModal_Model->relationModel
Open
$this->relationModel = Vtiger_Relation_Model::getInstance($srcModuleModel, $this->get('module'));
- Exclude checks
Saw possibly unextractable annotation for a fragment of comment '* @param string name of the module':
after string,
did not see an element name (will guess based on comment order) Open
* @param string name of the module
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
return (new App\Db\Query())->select(['tree'])->from('u_#__crmentity_rel_tree')
- Exclude checks
Reference to undeclared property \Vtiger_TreeCategoryModal_Model->lastIdinTree
Open
++$this->lastIdinTree;
- Exclude checks
Returning type array<int>|array<int>|array<int>|array<int>|array{}</int></int></int></int>
but getTreeList()
is declared to return string
Open
return $trees;
- Exclude checks
Argument 1 (arr1)
is string
but \array_merge()
takes array
Open
return array_merge($this->getTreeList(), $this->getRecords());
- Exclude checks
Reference to undeclared property \Vtiger_TreeCategoryModal_Model->lastIdinTree
Open
$this->lastIdinTree = $lastId;
- Exclude checks
Reference to undeclared property \Vtiger_TreeCategoryModal_Model->relationModel
Open
if (!isset($this->relationModel)) {
- Exclude checks
Reference to undeclared property \Vtiger_TreeCategoryModal_Model->relationModel
Open
return $this->relationModel;
- Exclude checks
Each class must be in a namespace of at least one level (a top-level vendor name) Open
class Vtiger_TreeCategoryModal_Model extends \App\Base
- Exclude checks
The class Vtiger_TreeCategoryModal_Model is not named in CamelCase. Open
class Vtiger_TreeCategoryModal_Model extends \App\Base
{
public static $_cached_instance;
/**
- 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
The property $_cached_instance is not named in camelCase. Open
class Vtiger_TreeCategoryModal_Model extends \App\Base
{
public static $_cached_instance;
/**
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Property name "$_cached_instance" should not be prefixed with an underscore to indicate visibility Open
public static $_cached_instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- 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
return $this->getRelationModel()->privilegeToDelete();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Load tree.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$trees = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'type' => 'category',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tree['state']['disabled'] = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $_cached_instance;
- 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
$selected = $this->getSelectedTreeList();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('moduleName');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getTemplate()
- 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
return $fieldTemp;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getInstance(Vtiger_Module_Model $moduleModel)
- 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
* @return mixed
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($this->has('relationType')) {
- 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
$lastId = 0;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
while ($row = $dataReader->read()) {
- 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 (!$isDeletable && $checked) {
- Exclude checks
Line exceeds 120 characters; contains 238 characters Open
$fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param Vtiger_Module_Model $moduleModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$_cached_instance[$moduleName] = $instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool|\Vtiger_Relation_Model
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getRelationModel()
- 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 getRelationType()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return bool
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['templateid' => $this->getTemplate()])
- 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
* @return string Module name
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('fieldTemp');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('fieldTemp', $fieldTemp);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(self::$_cached_instance[$moduleName])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$_cached_instance[$moduleName];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->relationModel;
- 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
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getTreeList()
- 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
$pieces = explode('::', $row['parentTree']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tree = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($row['icon'])) {
- 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
}
- 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 getTreeData()
- 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
* Load tree ID.
- 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->relationModel = Vtiger_Relation_Model::getInstance($srcModuleModel, $this->get('module'));
- 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
'text' => \App\Language::translate($row['name'], $this->getModuleName()),
- 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 ($treeID > $lastId) {
- 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
$fieldTemp = (new \App\Db\Query())->select(['tablename', 'columnname', 'fieldname', 'fieldlabel', 'fieldparams'])->from('vtiger_field')->where(['uitype' => 302, 'tabid' => \App\Module::getModuleId($this->getModuleName())])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Static Function to get the instance of Vtiger TreeView Model for the given Vtiger Module Model.
- 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
* Function check if record is deletable.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$isDeletable = $this->getRelationModel()->privilegeToTreeDelete();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$checked = \in_array($row['tree'], $selected);
- 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
* Gets relation model.
- 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
$treeID = (int) ltrim($row['tree'], 'T');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getModuleName()
- 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
public function isDeletable()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->from('vtiger_trees_templates_data')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get the Module Name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('relationType');
- 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
'id' => $treeID,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'parent' => 0 == $parent ? '#' : $parent,
- 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
* Load tree field info.
- 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
$instance = new $modelClassName();
- 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
* Gets relation 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
return array_merge($this->getTreeList(), $this->getRecords());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($checked) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tree['category'] = ['checked' => true];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getTreeField()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$srcModuleModel = Vtiger_Module_Model::getInstance($this->get('srcModule'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->get('relationType');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$dataReader = (new App\Db\Query())
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parent = (int) ltrim(prev($pieces), 'T');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$lastId = $treeID;
- 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
* @return Vtiger_TreeView_Model instance
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->set('module', $moduleModel)->set('moduleName', $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
if ($this->has('fieldTemp')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleName = $moduleModel->get('name');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'TreeCategoryModal', $moduleName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$_cached_instance[$moduleName];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->createCommand()->query();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$trees[] = $tree;
- 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
}
- 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
$listEntries = $this->getSelectedRecords(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'category' => ['checked' => $selected]
- 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
$isDeletable = $this->isDeletable();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parent = (int) ltrim($item->get($fieldName), 'T');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $listViewModel->getAllEntries();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (2 == $this->getRelationType()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tree = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
++$this->lastIdinTree;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$isDeletable && $selected) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->getTreeField()['fieldparams'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string name of the module
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($this->relationModel)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->set('relationType', $this->getRelationModel()->getRelationType());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
end($pieces);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'record_id' => $row['tree'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tree['icon'] = $row['icon'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
->where(['crmid' => $this->get('srcRecord'), 'relmodule' => $this->get('module')->getId()])
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listViewModel = Vtiger_ListView_Model::getInstanceForPopup($this->getModuleName(), $this->get('srcModule'));
- 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
return $entries;
- 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
'parent' => 0 == $parent ? '#' : $parent,
- 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
$listViewModel->getQueryGenerator()->setField($this->getTreeField()['fieldname']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldName = $this->getTreeField()['fieldname'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$tree[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'text' => $item->getName(),
- 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
private function getSelectedTreeList()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return (new App\Db\Query())->select(['tree'])->from('u_#__crmentity_rel_tree')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$parentRecordModel = Vtiger_Record_Model::getInstanceById($this->get('srcRecord'), $this->get('srcModule'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($this->get('srcModule'))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$selectedRecords = $this->getSelectedRecords();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'id' => $this->lastIdinTree,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'record_id' => $item->getId(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $tree;
- 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
$listViewModel->set('src_module', $this->get('srcModule'));
- 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
'type' => 'category',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'attr' => 'record',
- 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
private function getSelectedRecords($onlyKeys = true)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listViewModel->set('src_record', $this->get('srcRecord'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$listEntries = $this->getAllRecords();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->lastIdinTree = $lastId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationListView = Vtiger_RelationListView_Model::getInstance($parentRecordModel, $this->getModuleName());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entries = $relationListView->getAllEntries();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$state = ['selected' => $selected];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$state['disabled'] = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getAllRecords()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Function to get selected item in the tree.
- 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
'state' => $state,
- 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
->column();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return array_keys($entries);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($listEntries as $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $trees;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- 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 ($onlyKeys) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getRecords()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$selected = \in_array($item->getId(), $selectedRecords);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'icon' => "js-detail__icon yfm-{$this->getModuleName()}",
- Exclude checks
Class name "Vtiger_TreeCategoryModal_Model" is not in camel caps format Open
class Vtiger_TreeCategoryModal_Model extends \App\Base
- Exclude checks
The variable $_cached_instance is not named in camelCase. Open
public static function getInstance(Vtiger_Module_Model $moduleModel)
{
$moduleName = $moduleModel->get('name');
if (isset(self::$_cached_instance[$moduleName])) {
return self::$_cached_instance[$moduleName];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_cached_instance is not named in camelCase. Open
public static function getInstance(Vtiger_Module_Model $moduleModel)
{
$moduleName = $moduleModel->get('name');
if (isset(self::$_cached_instance[$moduleName])) {
return self::$_cached_instance[$moduleName];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_cached_instance is not named in camelCase. Open
public static function getInstance(Vtiger_Module_Model $moduleModel)
{
$moduleName = $moduleModel->get('name');
if (isset(self::$_cached_instance[$moduleName])) {
return self::$_cached_instance[$moduleName];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $_cached_instance is not named in camelCase. Open
public static function getInstance(Vtiger_Module_Model $moduleModel)
{
$moduleName = $moduleModel->get('name');
if (isset(self::$_cached_instance[$moduleName])) {
return self::$_cached_instance[$moduleName];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}