Passed
Push — developer ( 7a4da1...0584e9 )
by Radosław
25:41
created

Vtiger_GetAdvancedReferences_Relation::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * Get advanced references file that includes basic operations on relations.
4
 *
5
 * @package   Relation
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Adrian Kon <[email protected]>
10
 */
11
12
/**
13
 * Vtiger_GetAdvancedReferences_Relation class.
14
 */
15
class Vtiger_GetAdvancedReferences_Relation extends \App\Relation\RelationAbstraction
16
{
17
	/** {@inheritdoc} */
18
	public function getRelationType(): int
19
	{
20
		return Vtiger_Relation_Model::RELATION_AR;
21
	}
22
23
	/** {@inheritdoc} */
24
	public function getQuery()
25
	{
26
		$fieldModel = $this->relationModel->getRelationField();
27
		$queryGenerator = $this->relationModel->getQueryGenerator();
28
		$queryGenerator->setDistinct('srequirementscardsid');
29
		$relationModuleModel = Vtiger_Inventory_Model::getInstance($this->relationModel->getRelationModuleModel()->getName());
0 ignored issues
show
Bug introduced by
$this->relationModel->ge...oduleModel()->getName() of type boolean is incompatible with the type string expected by parameter $moduleName of Vtiger_Inventory_Model::getInstance(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

29
		$relationModuleModel = Vtiger_Inventory_Model::getInstance(/** @scrutinizer ignore-type */ $this->relationModel->getRelationModuleModel()->getName());
Loading history...
30
		$inventoryTable = $relationModuleModel->getDataTableName();
31
		$entityModel = $queryGenerator->getEntityModel();
32
		$parentTableName = $entityModel->table_name;
33
		$parentTableId = $entityModel->table_index;
34
		$subQuery = (new \App\Db\Query())->select('crmid')->from($inventoryTable)->where(["{$inventoryTable}.{$fieldModel->getColumnName()}" => $this->relationModel->get('parentRecord')->getId()]);
35
		$queryGenerator->addNativeCondition(["{$parentTableName}.{$parentTableId}" => $subQuery]);
36
	}
37
38
	/** {@inheritdoc} */
39
	public function create(int $sourceRecordId, int $destinationRecordId): bool
40
	{
41
		return false;
42
	}
43
44
	/** {@inheritdoc} */
45
	public function delete(int $sourceRecordId, int $destinationRecordId): bool
46
	{
47
		return false;
48
	}
49
50
	/** {@inheritdoc} */
51
	public function transfer(int $relatedRecordId, int $fromRecordId, int $toRecordId): bool
52
	{
53
		return false;
54
	}
55
}
56