Function relations
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
public static function relations(int $sourceId, array $records)
{
$sourceRecord = \Vtiger_Record_Model::getInstanceById($sourceId);
foreach ($records as $recordId) {
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId);
- 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
Method relations
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function relations(int $sourceId, array $records)
{
$sourceRecord = \Vtiger_Record_Model::getInstanceById($sourceId);
foreach ($records as $recordId) {
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId);
Function recordData
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function recordData(\Vtiger_Record_Model $recordModel, array $migrate)
{
foreach ($migrate as $recordId => $fields) {
if (!Record::isExists($recordId) || (($sourceRecord = \Vtiger_Record_Model::getInstanceById($recordId)) && (!$sourceRecord->isViewable()))) {
throw new Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- 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
The method recordData() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public static function recordData(\Vtiger_Record_Model $recordModel, array $migrate)
{
foreach ($migrate as $recordId => $fields) {
if (!Record::isExists($recordId) || (($sourceRecord = \Vtiger_Record_Model::getInstanceById($recordId)) && (!$sourceRecord->isViewable()))) {
throw new Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method relations() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10. Open
public static function relations(int $sourceId, array $records)
{
$sourceRecord = \Vtiger_Record_Model::getInstanceById($sourceId);
foreach ($records as $recordId) {
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 50 to the 15 allowed. Open
public static function relations(int $sourceId, array $records)
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Missing class import via use statement (line '31', column '14'). Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 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
Avoid assigning values to variables in if clauses and the like (line '58', column '42'). Open
public static function recordData(\Vtiger_Record_Model $recordModel, array $migrate)
{
foreach ($migrate as $recordId => $fields) {
if (!Record::isExists($recordId) || (($sourceRecord = \Vtiger_Record_Model::getInstanceById($recordId)) && (!$sourceRecord->isViewable()))) {
throw new Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class '\Vtiger_Record_Model' in method 'relations'. Open
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId);
- 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 recordData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
throw new Exceptions\FieldException('ERR_FIELD_NOT_FOUND');
}
- 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_Relation_Model' in method 'relations'. Open
$relations = \Vtiger_Relation_Model::getAllRelations($recordModel->getModule(), false, true, 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 '\Vtiger_Relation_Model' in method 'relations'. Open
foreach (\Vtiger_Relation_Model::getAllRelations($sourceRecord->getModule(), false, true, false) as $sourceRelation) {
- 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 assigning values to variables in if clauses and the like (line '30', column '41'). Open
public static function transfer(int $recordId, array $migrate)
{
if (!Record::isExists($recordId) || (($record = \Vtiger_Record_Model::getInstanceById($recordId)) && !$record->isViewable())) {
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid using static access to class 'App\Record' in method 'transfer'. Open
if (!Record::isExists($recordId) || (($record = \Vtiger_Record_Model::getInstanceById($recordId)) && !$record->isViewable())) {
- 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 '\ModComments' in method 'relations'. Open
\ModComments::transferRecords($recordId, $sourceId);
- 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\Record' in method 'recordData'. Open
if (!Record::isExists($recordId) || (($sourceRecord = \Vtiger_Record_Model::getInstanceById($recordId)) && (!$sourceRecord->isViewable()))) {
- 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_Record_Model' in method 'recordData'. Open
if (!Record::isExists($recordId) || (($sourceRecord = \Vtiger_Record_Model::getInstanceById($recordId)) && (!$sourceRecord->isViewable()))) {
- 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 '\CRMEntity' in method 'relations'. Open
\CRMEntity::getInstance('ModComments');
- 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_Record_Model' in method 'transfer'. Open
if (!Record::isExists($recordId) || (($record = \Vtiger_Record_Model::getInstanceById($recordId)) && !$record->isViewable())) {
- 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_Record_Model' in method 'relations'. Open
$sourceRecord = \Vtiger_Record_Model::getInstanceById($sourceId);
- 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 "ERR_NO_PERMISSIONS_FOR_THE_RECORD" 3 times. Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 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.
Call to undeclared method \App\Db\Query::select
Open
$relTrees = $destRelation->getRelationTreeQuery()->select(['ttd.tree', 'crmid'])->createCommand()->queryAllByGroup();
- Exclude checks
Call to undeclared method \App\Db::beginTransaction
Open
$transaction = Db::getInstance()->beginTransaction();
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = $sourceRelation->set('parentRecord', $sourceRecord)->getQuery()->setFields(['id']);
- Exclude checks
Call to method setFields
from undeclared class \App\QueryGenerator
(Did you mean class \Tests\App\QueryGenerator) Open
$queryGenerator = $destRelation->set('parentRecord', $recordModel)->getQuery()->setFields(['id']);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$sourceTrees = $sourceRelation->getRelationTreeQuery()->select(['ttd.tree', 'crmid'])->createCommand()->queryAllByGroup();
- 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 (!Record::isExists($recordId) || (($record = \Vtiger_Record_Model::getInstanceById($recordId)) && !$record->isViewable())) {
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
if (!Record::isExists($recordId) || (($record = \Vtiger_Record_Model::getInstanceById($recordId)) && !$record->isViewable())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws Exceptions\FieldException
- 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
* Update record data.
- 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
$sourceFieldModel = $sourceRecord->getField($source);
- 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 static function recordData(\Vtiger_Record_Model $recordModel, array $migrate)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param int $recordId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \App\Exceptions\NoPermittedToRecord
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws \Throwable
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transaction = Db::getInstance()->beginTransaction();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws Exceptions\NoPermittedToRecord
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $migrate
- 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
$transaction->rollBack();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$targetFieldModel = $recordModel->getField($target);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$transaction->commit();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $migrate [$recordId => [$source => $target, ...], ...]
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new \App\Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 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
if (!Record::isExists($recordId) || (($sourceRecord = \Vtiger_Record_Model::getInstanceById($recordId)) && (!$sourceRecord->isViewable()))) {
- Exclude checks
Line exceeds 120 characters; contains 153 characters Open
if (!Record::isExists($recordId) || (($sourceRecord = \Vtiger_Record_Model::getInstanceById($recordId)) && (!$sourceRecord->isViewable()))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Transfer.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function transfer(int $recordId, array $migrate)
- 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 Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 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
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($recordModel->getModule()->isCommentEnabled() && $sourceRecord->getModule()->isCommentEnabled()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$destRelation->deleteRelationTree($recordModel->getId(), $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
* @param \Vtiger_Record_Model $recordModel
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($migrate as $recordId => $fields) {
- 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
foreach ($relations as $destRelation) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->permissions = false;
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
$queryGenerator = $destRelation->set('parentRecord', $recordModel)->getQuery()->setFields(['id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (array_diff($relationIds, $sourceRelationIds) as $relId) {
- 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 (\Throwable $ex) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw new Exceptions\FieldException('ERR_FIELD_NOT_FOUND');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceRelation->transfer([$relId => $recordModel->getId()]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$destRelation->transferDelete($relId);
- 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
$record->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$record->ext['modificationType'] = \ModTracker_Record_Model::TRANSFER_EDIT;
- 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
foreach ($fields as $source => $target) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel = \Vtiger_Record_Model::getInstanceById($recordId);
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
if ($sourceFieldModel && $sourceFieldModel->isViewEnabled() && $targetFieldModel && $targetFieldModel->isEditable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$recordModel->isViewable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$recordModel->set($target, $sourceFieldModel->getUITypeModel()->getDuplicateValue($sourceRecord));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\CRMEntity::getInstance('ModComments');
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$queryGenerator = $sourceRelation->set('parentRecord', $sourceRecord)->getQuery()->setFields(['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
$queryGenerator->setStateCondition('All');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (\Vtiger_Relation_Model::getAllRelations($sourceRecord->getModule(), false, true, false) as $sourceRelation) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (array_intersect($relationIds, $sourceRelationIds) as $relId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$destRelation = clone $destRelation;
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
$sourceTrees = $sourceRelation->getRelationTreeQuery()->select(['ttd.tree', 'crmid'])->createCommand()->queryAllByGroup();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = $sourceRelation->set('parentRecord', $sourceRecord)->getQuery()->setFields(['id']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator->setStateCondition('All');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$destRelation->transferDelete($relId);
- 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
static::relations($recordId, array_keys($migrate));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceTrees = $sourceRelation->getRelationTreeQuery()->select(['ttd.tree', 'crmid'])->createCommand()->queryAllByGroup();
- 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
static::recordData($record, $migrate);
- 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
* Transfer relations.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$destRelation->isDirectRelation()) {
- 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
* @param int $sourceId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function relations(int $sourceId, array $records)
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
foreach (\Vtiger_Relation_Model::getAllRelations($sourceRecord->getModule(), false, true, false) as $sourceRelation) {
- 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
foreach ($relTrees as $tree => $crmid) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!isset($sourceTrees[$tree])) {
- 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
$queryGenerator->permissions = 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
* @param array $records
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\ModComments::transferRecords($recordId, $sourceId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws Exceptions\NoPermittedToRecord
- 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 Exceptions\NoPermittedToRecord('ERR_NO_PERMISSIONS_FOR_THE_RECORD', 406);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceRelationIds = $queryGenerator->createQuery()->column();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceRelation->transferTree([$tree => $crmid]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
throw $ex;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($sourceFieldModel && $sourceFieldModel->isViewEnabled() && $targetFieldModel && $targetFieldModel->isEditable()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($sourceRelation->get('related_tabid') === $destRelation->get('related_tabid') && $sourceRelation->get('name') === $destRelation->get('name') && $sourceRelation->get('field_name') === $destRelation->get('field_name')) {
- Exclude checks
Line exceeds 120 characters; contains 242 characters Open
if ($sourceRelation->get('related_tabid') === $destRelation->get('related_tabid') && $sourceRelation->get('name') === $destRelation->get('name') && $sourceRelation->get('field_name') === $destRelation->get('field_name')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relationIds = $queryGenerator->createQuery()->column();
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
$relTrees = $destRelation->getRelationTreeQuery()->select(['ttd.tree', 'crmid'])->createCommand()->queryAllByGroup();
- 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
$sourceRelation = clone $sourceRelation;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$sourceRecord = \Vtiger_Record_Model::getInstanceById($sourceId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($records as $recordId) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relations = \Vtiger_Relation_Model::getAllRelations($recordModel->getModule(), false, true, false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$queryGenerator = $destRelation->set('parentRecord', $recordModel)->getQuery()->setFields(['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
}
- 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 ($destRelation->isTreeRelation()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$relTrees = $destRelation->getRelationTreeQuery()->select(['ttd.tree', 'crmid'])->createCommand()->queryAllByGroup();
- Exclude checks