fix
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Bx\Nullable\App;
|
||||
|
||||
|
||||
use Bx\Nullable\Facade\DefaultDefines;
|
||||
use Bx\Nullable\Facade\Defines;
|
||||
use Bx\Nullable\Facade\DefaultServiceFacade;
|
||||
@@ -1,9 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Bx\Nullable\Factory;
|
||||
|
||||
|
||||
use Bx\Nullable\Collection\NullableCollection;
|
||||
use Bx\Nullable\Entity\NullableEntity;
|
||||
use Bx\Nullable\ORM\NullableTable;
|
||||
@@ -1,11 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Bx\Nullable\ORM;
|
||||
|
||||
|
||||
use Bitrix\Main\ORM\Fields\DatetimeField;
|
||||
use Bitrix\Main\Type\DateTime;
|
||||
use Exception;
|
||||
use Wt\Core\ORM\ADataManager;
|
||||
|
||||
class NullableTable extends ADataManager
|
||||
@@ -33,7 +32,7 @@ class NullableTable extends ADataManager
|
||||
|
||||
public static function getMap()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'ID' => new \Bitrix\Main\Entity\IntegerField('ID', [
|
||||
'primary' => true,
|
||||
'autocomplete' => true,
|
||||
@@ -47,39 +46,39 @@ class NullableTable extends ADataManager
|
||||
'title' => 'UpdatedAt',
|
||||
'user_edit' => false,
|
||||
]),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @param array $fields
|
||||
* @param $primary
|
||||
* @param array $data
|
||||
* @return \Bitrix\Main\ORM\Data\UpdateResult
|
||||
* @throws \Bitrix\Main\ObjectException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function update($id, array $fields)
|
||||
public static function update($primary, array $data)
|
||||
{
|
||||
foreach (static::getEntity()->getFields() as $field){
|
||||
if(is_a($field, DatetimeField::class)){
|
||||
if(isset($fields[$field->getName()]) && !is_a($fields[$field->getName()], DateTime::class)) {
|
||||
$fields[$field->getName()] = new \Bitrix\Main\Type\DateTime($fields[$field->getName()]);
|
||||
if(isset($data[$field->getName()]) && !is_a($data[$field->getName()], DateTime::class)) {
|
||||
$data[$field->getName()] = new \Bitrix\Main\Type\DateTime($data[$field->getName()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fields = array_merge($fields, [
|
||||
$data = array_merge($data, [
|
||||
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(), // date(CDatabase::DateFormatToPHP(FORMAT_DATETIME))
|
||||
]);
|
||||
unset($fields['CREATED_AT']);
|
||||
unset($data['CREATED_AT']);
|
||||
|
||||
$result = parent::update($id, $fields);
|
||||
return $result;
|
||||
return parent::update($primary, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
* @return \Bitrix\Main\ORM\Data\AddResult
|
||||
* @throws \Bitrix\Main\ObjectException
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function add(array $fields)
|
||||
{
|
||||
@@ -88,7 +87,6 @@ class NullableTable extends ADataManager
|
||||
'UPDATED_AT' => new \Bitrix\Main\Type\DateTime(),
|
||||
]);
|
||||
|
||||
$result = parent::add($fields);
|
||||
return $result;
|
||||
return parent::add($fields);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user