add any repository and new-style models
This commit is contained in:
parent
ffddc8d780
commit
7b9c70bded
5 changed files with 212 additions and 25 deletions
|
@ -1613,7 +1613,7 @@ class intaro_retailcrm extends CModule
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add bonus pay system
|
||||
*/
|
||||
|
@ -1625,37 +1625,37 @@ class intaro_retailcrm extends CModule
|
|||
['ACTION_FILE', '=', self::BONUS_PAY_SYSTEM_CODE],
|
||||
])
|
||||
->fetchCollection();
|
||||
|
||||
|
||||
if (count($arrPaySystemAction) === 0) {
|
||||
$result = PaySystemActionTable::add(
|
||||
[
|
||||
'NAME' => self::BONUS_PAY_SYSTEM_NAME,
|
||||
'PSA_NAME' => self::BONUS_PAY_SYSTEM_NAME,
|
||||
'ACTION_FILE' => self::BONUS_PAY_SYSTEM_CODE,
|
||||
'DESCRIPTION' => self::BONUS_PAY_SYSTEM_DESCRIPTION,
|
||||
'RESULT_FILE' => '',
|
||||
'NEW_WINDOW' => 'N',
|
||||
'ENCODING' => 'utf-8',
|
||||
'ACTIVE' => 'Y',
|
||||
'HAVE_PAYMENT' => 'Y',
|
||||
'HAVE_ACTION' => 'N',
|
||||
'AUTO_CHANGE_1C' => 'N',
|
||||
'HAVE_RESULT' => 'N',
|
||||
'HAVE_PRICE' => 'N',
|
||||
'HAVE_PREPAY' => 'N',
|
||||
'HAVE_RESULT_RECEIVE' => 'N',
|
||||
'ALLOW_EDIT_PAYMENT' => 'Y',
|
||||
'IS_CASH' => 'N',
|
||||
'CAN_PRINT_CHECK' => 'N',
|
||||
'NAME' => self::BONUS_PAY_SYSTEM_NAME,
|
||||
'PSA_NAME' => self::BONUS_PAY_SYSTEM_NAME,
|
||||
'ACTION_FILE' => self::BONUS_PAY_SYSTEM_CODE,
|
||||
'DESCRIPTION' => self::BONUS_PAY_SYSTEM_DESCRIPTION,
|
||||
'RESULT_FILE' => '',
|
||||
'NEW_WINDOW' => 'N',
|
||||
'ENCODING' => 'utf-8',
|
||||
'ACTIVE' => 'Y',
|
||||
'HAVE_PAYMENT' => 'Y',
|
||||
'HAVE_ACTION' => 'N',
|
||||
'AUTO_CHANGE_1C' => 'N',
|
||||
'HAVE_RESULT' => 'N',
|
||||
'HAVE_PRICE' => 'N',
|
||||
'HAVE_PREPAY' => 'N',
|
||||
'HAVE_RESULT_RECEIVE' => 'N',
|
||||
'ALLOW_EDIT_PAYMENT' => 'Y',
|
||||
'IS_CASH' => 'N',
|
||||
'CAN_PRINT_CHECK' => 'N',
|
||||
'ENTITY_REGISTRY_TYPE' => 'ORDER',
|
||||
'XML_ID' => 'intaro_' . randString(15),
|
||||
'XML_ID' => 'intaro_' . randString(15),
|
||||
]
|
||||
);
|
||||
$updateData = [
|
||||
'PAY_SYSTEM_ID' => $result->getId(),
|
||||
'PARAMS' => serialize(['BX_PAY_SYSTEM_ID' => $result->getId()]),
|
||||
'PARAMS' => serialize(['BX_PAY_SYSTEM_ID' => $result->getId()]),
|
||||
];
|
||||
|
||||
|
||||
PaySystemActionTable::update($result->getId(), $updateData);
|
||||
}
|
||||
}
|
||||
|
@ -1712,5 +1712,4 @@ class intaro_retailcrm extends CModule
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ use Intaro\RetailCrm\Model\Bitrix\OrderProps;
|
|||
*/
|
||||
class OrderPropsRepository extends AbstractRepository
|
||||
{
|
||||
/**
|
||||
/**
|
||||
* @param array $select
|
||||
* @param array $where
|
||||
* @return \Intaro\RetailCrm\Model\Bitrix\OrderProps|null
|
||||
|
|
|
@ -24,6 +24,7 @@ class PersonTypeRepository extends AbstractRepository
|
|||
/**
|
||||
* @param array $select
|
||||
* @param array $where
|
||||
*
|
||||
* @return \Bitrix\Main\Type\Collection|null|Bitrix\Sale\Internals\EO_PersonType_Collection
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
|
|
|
@ -41,6 +41,7 @@ class ToModuleRepository extends AbstractRepository
|
|||
/**
|
||||
* @param array $select
|
||||
* @param array $where
|
||||
*
|
||||
* @return \Bitrix\Main\Type\Collection|Intaro\RetailCrm\Model\Bitrix\ORM\EO_ToModule_Collection|null
|
||||
* @throws \Bitrix\Main\ArgumentException
|
||||
* @throws \Bitrix\Main\ObjectPropertyException
|
||||
|
|
186
intaro.retailcrm/lib/service/annotationgenerator.php
Normal file
186
intaro.retailcrm/lib/service/annotationgenerator.php
Normal file
|
@ -0,0 +1,186 @@
|
|||
<?php
|
||||
|
||||
function bitrixNameToCamelCase($string, $capitalizeFirstCharacter = false)
|
||||
{
|
||||
$str = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($string))));
|
||||
|
||||
if (!$capitalizeFirstCharacter) {
|
||||
$str[0] = strtolower($str[0]);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
$typeMapping = [
|
||||
'integer' => 'int',
|
||||
'string' => 'string',
|
||||
'text' => 'string',
|
||||
'boolean' => 'bool',
|
||||
'datetime' => 'DateTime',
|
||||
'date' => 'DateTime'
|
||||
];
|
||||
|
||||
$fieldMap = array(
|
||||
'ID' => array(
|
||||
'primary' => true,
|
||||
'autocomplete' => true,
|
||||
'data_type' => 'integer',
|
||||
'format' => '/^[0-9]{1,11}$/',
|
||||
),
|
||||
'PERSON_TYPE_ID' => array(
|
||||
'required' => true,
|
||||
'data_type' => 'integer',
|
||||
'format' => '/^[0-9]{1,11}$/',
|
||||
),
|
||||
'NAME' => array(
|
||||
'required' => true,
|
||||
'data_type' => 'string',
|
||||
|
||||
|
||||
),
|
||||
'TYPE' => array(
|
||||
'required' => true,
|
||||
'data_type' => 'string',
|
||||
|
||||
),
|
||||
'REQUIRED' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
|
||||
),
|
||||
'DEFAULT_VALUE' => array(
|
||||
'data_type' => 'string',
|
||||
|
||||
|
||||
|
||||
|
||||
),
|
||||
'SORT' => array(
|
||||
'data_type' => 'integer',
|
||||
'format' => '/^[0-9]{1,11}$/',
|
||||
|
||||
),
|
||||
'USER_PROPS' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'IS_LOCATION' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'PROPS_GROUP_ID' => array(
|
||||
'required' => true,
|
||||
'data_type' => 'integer',
|
||||
'format' => '/^[0-9]{1,11}$/',
|
||||
),
|
||||
'DESCRIPTION' => array(
|
||||
'data_type' => 'string',
|
||||
|
||||
|
||||
),
|
||||
'IS_EMAIL' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'IS_PROFILE_NAME' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'IS_PAYER' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'IS_LOCATION4TAX' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'IS_FILTERED' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
|
||||
),
|
||||
'CODE' => array(
|
||||
'data_type' => 'string',
|
||||
|
||||
|
||||
),
|
||||
'IS_ZIP' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'IS_PHONE' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'IS_ADDRESS' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'ACTIVE' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'UTIL' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'INPUT_FIELD_LOCATION' => array(
|
||||
'data_type' => 'integer',
|
||||
'format' => '/^[0-9]{1,11}$/',
|
||||
),
|
||||
'MULTIPLE' => array(
|
||||
'data_type' => 'boolean',
|
||||
'values' => array('N', 'Y'),
|
||||
),
|
||||
'SETTINGS' => array(
|
||||
'data_type' => 'string',
|
||||
|
||||
|
||||
|
||||
),
|
||||
|
||||
'GROUP' => array(
|
||||
'data_type' => 'Bitrix\Sale\Internals\OrderPropsGroupTable',
|
||||
'reference' => array('=this.PROPS_GROUP_ID' => 'ref.ID'),
|
||||
'join_type' => 'LEFT',
|
||||
),
|
||||
'PERSON_TYPE' => array(
|
||||
'data_type' => 'Bitrix\Sale\Internals\PersonTypeTable',
|
||||
'reference' => array('=this.PERSON_TYPE_ID' => 'ref.ID'),
|
||||
'join_type' => 'LEFT',
|
||||
),
|
||||
'ENTITY_REGISTRY_TYPE' => array(
|
||||
'data_type' => 'string',
|
||||
),
|
||||
'XML_ID' => array(
|
||||
'data_type' => 'string',
|
||||
),
|
||||
); //replace this array AnyTable::getMap();
|
||||
|
||||
foreach ($fieldMap as $fieldName => $fieldType) {
|
||||
if (!is_string($fieldName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$setArgumentName = bitrixNameToCamelCase($fieldName);
|
||||
$getter = bitrixNameToCamelCase('GET_' . $fieldName);
|
||||
$setter = bitrixNameToCamelCase('SET_' . $fieldName);
|
||||
$dataType = '';
|
||||
|
||||
if (isset($typeMapping[$fieldType['data_type']])) {
|
||||
$dataType = $typeMapping[$fieldType['data_type']];
|
||||
} else {
|
||||
if (strpos($fieldType['data_type'], '\\') !== false) {
|
||||
if (class_exists($fieldType['data_type'])) {
|
||||
$dataType = $fieldType['data_type'];
|
||||
} else {
|
||||
$dataType = 'mixed';
|
||||
}
|
||||
} else {
|
||||
$dataType = $fieldType['data_type'];
|
||||
}
|
||||
}
|
||||
|
||||
printf(' * @method %s %s()' . PHP_EOL, empty($dataType) ? 'mixed' : $dataType, $getter);
|
||||
printf(' * @method void %s(%s%s$%s)' . PHP_EOL, $setter, $dataType == 'mixed' ? '' : $dataType, $dataType == 'mixed' ? '' : ' ', $setArgumentName);
|
||||
}
|
Loading…
Add table
Reference in a new issue