api/webservice/WebservicePremium/BaseModule/SourceBasedData.php
Avoid using static access to class '\Vtiger_Record_Model' in method 'put'. Open
Open
$recordModel = \Vtiger_Record_Model::getCleanInstance($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
Possibly zero references to use statement for classlike/namespace OA
(\OpenApi\Annotations)
Open
Open
use OpenApi\Annotations as OA;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* tags={"BaseModule"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\JsonContent(ref="#/components/schemas/BaseModule_Put_SourceBasedData_Request"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="sourceModule", type="string", description="Source module", example="Accounts"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="sourceModule", type="string", description="Source module", example="Accounts"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="sourceRecord", type="integer", description="Source record ID", example=221),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
public function put(): array
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
$moduleName = $this->controller->request->getModule();
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* oneOf={
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\XmlContent(ref="#/components/schemas/BaseModule_Put_SourceBasedData_Request"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="sourceRecordData", title="Record data", type="object", ref="#/components/schemas/Record_Edit_Details"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\XmlContent(ref="#/components/schemas/BaseModule_Put_SourceBasedData_Response"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* },
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* oneOf={
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* schema="BaseModule_Put_SourceBasedData_Response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* required={"data", "rawData"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* type="object",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\RequestBody(required=true, description="Contents of the request contains an associative array with the data record.",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Schema(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* title="Base module - Source-based data response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* required={"sourceModule", "sourceRecord"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* required={"status", "result"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
'rawData' => $raw
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="sourceRecord", type="integer", description="Source record ID", example=221),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* required={"sourceRecordData"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* required={"sourceRecordData"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* title="Base module - Source-based data response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* description="Data to auto-complete in compose view",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
$raw = $data = [];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
$recordModel->set($fieldName, $value);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* description="Get the record by sources",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* description="Get the record by sources",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* },
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Schema(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* schema="BaseModule_Put_SourceBasedData_Response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* tags={"BaseModule"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* description="Data to auto-complete in compose view",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* required={"status", "result"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\XmlContent(ref="#/components/schemas/BaseModule_Put_SourceBasedData_Request"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Parameter(name="moduleName", in="path", @OA\Schema(type="string"), description="Module name", required=true, example="Contacts"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Schema(type="object", title="Create a record from a related module",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Schema(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="data", title="Record data", type="object", ref="#/components/schemas/Record_Display_Details"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
foreach (array_keys($raw) as $fieldName) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
'data' => $data,
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\JsonContent(ref="#/components/schemas/BaseModule_Put_SourceBasedData_Response"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\XmlContent(ref="#/components/schemas/BaseModule_Put_SourceBasedData_Response"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* required={"sourceModule", "sourceRecord"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Schema(type="object", title="Create a record from a reference field",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* summary="Gets the record data from sources",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\RequestBody(required=true, description="Contents of the request contains an associative array with the data record.",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* schema="BaseModule_Put_SourceBasedData_Request",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* title="Base module - Source-based data request",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="sourceRecordData", title="Record data", type="object", ref="#/components/schemas/Record_Edit_Details"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
return [
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Response(response=200, description="Source-based data response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* type="object",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Schema(type="object", title="Create a record from a related module",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="result", type="object", title="Returns record data",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="data", title="Record data", type="object", ref="#/components/schemas/Record_Display_Details"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
foreach ($recordModel->getModule()->getValuesFromSource($this->controller->request) as $fieldName => $value) {
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Parameter(name="moduleName", in="path", @OA\Schema(type="string"), description="Module name", required=true, example="Contacts"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\JsonContent(ref="#/components/schemas/BaseModule_Put_SourceBasedData_Response"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Schema(
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* type="object",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Schema(type="object", title="Create a record from a reference field",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
*/
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* path="/webservice/WebservicePremium/{moduleName}/SourceBasedData",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* summary="Gets the record data from sources",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\JsonContent(ref="#/components/schemas/BaseModule_Put_SourceBasedData_Request"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Response(response=200, description="Source-based data response",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* schema="BaseModule_Put_SourceBasedData_Request",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
$recordModel = \Vtiger_Record_Model::getCleanInstance($moduleName);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="result", type="object", title="Returns record data",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* required={"data", "rawData"},
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* title="Base module - Source-based data request",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* type="object",
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="rawData", description="Raw record data", type="object", ref="#/components/schemas/Record_Raw_Details"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* @OA\Property(property="rawData", description="Raw record data", type="object", ref="#/components/schemas/Record_Raw_Details"),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
* ),
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
$raw[$fieldName] = $recordModel->getRawValue($fieldName);
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
Open
$data[$fieldName] = $recordModel->getModule()->getFieldByName($fieldName)->getUITypeModel()->getApiDisplayValue($recordModel->get($fieldName), $recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
Open
* @OA\Parameter(name="moduleName", in="path", @OA\Schema(type="string"), description="Module name", required=true, example="Contacts"),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
*
- Exclude checks
Line exceeds 120 characters; contains 142 characters Open
Open
* @OA\Property(property="rawData", description="Raw record data", type="object", ref="#/components/schemas/Record_Raw_Details"),
- Exclude checks
Line exceeds 120 characters; contains 189 characters Open
Open
* @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @return array
- Exclude checks
Line exceeds 120 characters; contains 131 characters Open
Open
* @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/** {@inheritdoc} */
- Exclude checks
Line exceeds 120 characters; contains 146 characters Open
Open
* @OA\Property(property="sourceRecordData", title="Record data", type="object", ref="#/components/schemas/Record_Edit_Details"),
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
Open
* @OA\Property(property="data", title="Record data", type="object", ref="#/components/schemas/Record_Display_Details"),
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
Open
* @OA\Property(property="sourceModule", type="string", description="Source module", example="Accounts"),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* path="/webservice/WebservicePremium/{moduleName}/SourceBasedData",
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* Put method - Gets the record data from sources.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
* @OA\Put(
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
Open
* @OA\RequestBody(required=true, description="Contents of the request contains an associative array with the data record.",
- Exclude checks
Line exceeds 120 characters; contains 169 characters Open
Open
$data[$fieldName] = $recordModel->getModule()->getFieldByName($fieldName)->getUITypeModel()->getApiDisplayValue($recordModel->get($fieldName), $recordModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
Open
public $allowedMethod = ['PUT'];
- Exclude checks