Файловый менеджер - Редактировать - /var/www/axolotl/data/www/axolotls.ru/www/bitrix/modules/salescenter/lib/model/metatable.php
Назад
<?php namespace Bitrix\SalesCenter\Model; use Bitrix\Main; use Bitrix\Main\ORM\Event; use Bitrix\Main\ORM\Fields\IntegerField; use Bitrix\Main\ORM\Fields\StringField; class MetaTable extends Main\ORM\Data\DataManager { const HASH_LENGTH = 8; /** * Returns DB table name for entity. * * @return string */ public static function getTableName() { return 'b_salescenter_meta'; } /** * Returns entity map definition. * * @return array */ public static function getMap() { return [ new IntegerField('ID', [ 'primary' => true, 'autocomplete' => true, ]), new StringField('HASH', [ 'unique' => true, 'required' => true, ]), new IntegerField('HASH_CRC', [ 'required' => true, ]), new IntegerField('USER_ID', [ 'required' => true, ]), new Main\ORM\Fields\TextField('META'), new IntegerField('META_CRC', [ 'required' => true, ]), ]; } /** * @return Main\ORM\Objectify\EntityObject|string */ public static function getObjectClass() { return Meta::class; } /** * @param Event $event * @return Main\ORM\EventResult */ public static function onBeforeAdd(Event $event) { $result = new Main\ORM\EventResult(); $hash = static::getHash(); $result->modifyFields([ 'HASH' => $hash, 'HASH_CRC' => static::getCrc($hash), 'META_CRC' => static::getCrc($event->getParameter('fields')['META']), ]); return $result; } /** * @param Event $event * @return Main\ORM\EventResult */ public static function onBeforeUpdate(Event $event) { $result = new Main\ORM\EventResult(); $result->unsetField('HASH'); $result->unsetField('HASH_CRC'); $result->modifyFields([ 'META_CRC' => static::getCrc($event->getParameter('fields')['META']), ]); return $result; } protected static function getHash() { do { $hash = randString(static::HASH_LENGTH); $isNew = true; $meta = Meta::getByHash($hash); if($meta) { $isNew = false; } } while (!$isNew); return $hash; } /** * @param string $str * @return int */ public static function getCrc($str) { return \CBXShortUri::Crc32($str); } }
| ver. 1.4 |
Github
|
.
| PHP 7.4.8 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка